Allow SSH Connection to Specific IP Address on Linux
To prevent unwanted connecting to your host from people and only allow connections to specific IP addresses, We have simple way to allow it in your server. Just try to follow the below steps,
For example would you like to allow All connection from address 192.168.0.100.
Any changes in your hosts.allow and hosts.deny file takes immediate effect.
Open the file hosts.deny and add the below line,
sshd: ALL EXCEPT 192.168.0.100
To allow multiple ip address :
sshd: ALL EXCEPT 192.168.0.100 192.168.0.101
Another method is use of a Firewall,
Allow IP Address 192.168.0.100 to SSH (port 1234) and check your ethernet name using ifconfig command
Deny all other SSH connections:
Save the iptables,
SSH Access to Specific IP for User:
Open your ssh configure file and update it
AllowUsers firstname.lastname@example.org email@example.com firstname.lastname@example.org