Tuesday, June 12, 2007

Limit SSH Access

For added security, one may want to limit access to a machine through SSH from certain machines only.

You need to edit your /etc/hosts.allow and /etc/hosts.deny files for this

Edit your /etc/hosts.allow file and add your trusted machines/IPs:

sshd: 101.212.332.444, 523.326.447.129
sshd: 1.2.3.

The first two match exact IP addresses, the third will allow any IP beginning with "1.2.3.".

Next edit your /etc/hosts.deny file and add the following line:
sshd: all

This will deny all logins from IPs not explicitly allowed in the hosts.allow file.

Caution: Make sure that the IP addresses entered are correct, otherwise you risk locking yourself out of the server

No comments: