Skip to main content

Posts

Showing posts from March, 2015

INSTALLING AND SETUPING ASTERISK FAIL2BAN IN LINUX/CENTOS SERVER

Step 1 : 

Install fail2ban in your server. Installation steps are described in http://ijasnahamed.blogspot.in/2015/03/install-and-setup-fail2ban-in.html from step 1 to step 6.

Step 2 : 

Open jail.local file

vi /etc/fail2ban/jail.local

Step 3 :

In this file , under asterisk-iptables heading, it will be shown like this as below

[asterisk-iptables]

enabled  = false
filter   = asterisk
action   = iptables-allports[name=ASTERISK, protocol=all]
           sendmail-whois[name=Asterisk, dest=you@example.com, sender=fail2ban@example.com]
logpath  = /var/log/asterisk/messages
maxretry = 5

or you may have

[asterisk]

enabled  = false
filter   = asterisk
action   = iptables-multiport[name=asterisk-tcp, port="5060,5061", protocol=tcp]
           iptables-multiport[name=asterisk-udp, port="5060,5061", protocol=udp]
           sendmail-whois[name=Asterisk, dest=you@example.com, sender=fail2ban@example.com]
logpath  = /var/log/asterisk/messages
maxretry = 10

Edit this to have parameters with followi…

ADDING FILES TO GIT IN LINUX WITHOUT HAVING A COMMON DIRECTORY

Sometimes, You all may have a situation to push files to git repositories which does not have a common directory. For example , take a case in linux. you need to push asterisk files to git repository as  backup. But asterisk files are situated in different directories. Such as ,

/etc/asterisk/
/var/lib/asterisk/
/var/spool/asterisk/
/var/log/asterisk/

In this case , there is no common directory.
To push this , you need to bring or direct contents of this folders to a common folder. For this symbolik link cannot be used.

So next way is to mount these files to a directory.

General Syntax is :

sudo mount --bind SOURCEDIRECTORY TARGETDIRECTORY

For above example ,
create a directory named GIT_PUSH in /var/www/html/
Now mount the files to this folder by ,

sudo mount --bind /etc/asterisk/ /var/www/html/GIT_PUSH/
sudo mount --bind /var/lib/asterisk/ /var/www/html/GIT_PUSH/
sudo mount --bind /var/spool/asterisk/ /var/www/html/GIT_PUSH/
sudo mount --bind /var/log/asterisk/ /var/www/html/GIT_PUSH/

Now al…

INSTALL AND SETUP SSH FAIL2BAN IN LINUX/CENTOS SERVER

Execute following commands to setup SSHFail2ban in your linux/centos server.

1) rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

If this is already installed, skip this step.

2) yum install fail2ban

3) if any error occur, clean yum and install fail2ban again by executing these command again.

yum clean all
    yum install fail2ban

4) If fail2ban installation is successfull.

cd /etc/fail2ban/

5) You cannot make any changes to "jail.conf" file. So make a copy of this file as "jail.local"

cp jail.conf jail.local

6) Open this file using any of your editor. I prefer vi editor.

vi jail.local

7) In this file , under ssh-iptables heading, it will be shown like this as below

[ssh-iptables]

enabled  = false
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           sendmail-whois[name=SSH, dest=root, sender=fail2ban@example.com]
logpath  = /var/log/secure
maxretry = 5

8) Change enabled parameter of ssh-iptables to true.

Set maxretr…

CREATING AND SIGN INTO LINUX/CENTOS SERVER USING SSH KEY

If "user_name" is a user in server "example.com" and you want to setup ssh key to this server and also able to login to this server using ssh key only.
Follow these command in the command line.

1) cd /home/user_name (user_name is the name of the user)

2) mkdir -p .ssh

3) chmod 0700 .ssh/

4) ssh-keygen -t rsa

Result printed will be something like below:

Result:
Generating public/private rsa key pair.                                        
Enter file in which to save the key (/home/user_name/.ssh/id_rsa):            
Enter passphrase (empty for no passphrase):                                    
Enter same passphrase again:                                                  
Your identification has been saved in /home/user_name/.ssh/id_rsa.            
Your public key has been saved in /home/user_name/.ssh/id_rsa.pub.            
The key fingerprint is:                                                        
5d:0f:b5:8e:d9:a4:4b:d0:1c:3f:b6:35:1d:44:89:27 user_name@ex…