Wednesday, October 29, 2008

Allow and deny IP for ssh in Linux

Allow and deny IP for ssh in Linux

We can allow and deny IP for ssh. To do this we have to change some configuration at /etc/host.deny and /etc/host.allow files. Suppose we want to deny 192.168.100.5, then we will edit the /etc/host.deny file and do some changes as follows.
vi /etc/host.deny
sshd:192.168.100.5
Save & exit
This will deny 192.168.100.5 to ssh.
Suppose we want to allow only 192.168.100.5 to ssh. Then we will edit two files as follows:
vi /etc/host.deny
sshd:all
save & exit
vi /etc/host.allow
sshd:192.168.100.5
save & exit
We can do the same by changing only at /etc/host.deny as follows:
vi /etc/host.deny
sshd:all except 192.168.100.5
save & exit

No comments: