Restrict SSH login to a specific IP or host
Step:1 – Deny all hosts
deny all incoming SSH connections
- Open file /etc/hosts.deny by using a text editor:
- vi /etc/hosts.deny
- Add the following line to deny all incoming SSH connections to the server:
- sshd: ALL
- Save and close the file.
Step:2 – Allow IP Address
- Open the file /etc/hosts.allow file by using a text editor
vi /etc/hosts.allow
- Add an
sshd
line to allow the IP address of your choice to connect by using public SSH. sshd:
IP- Save and close the file.