I want to block a ssh connection from particular IP address.
for example: my system IP address is 192.168.8.20,another two system is 192.168.8.11 and 192.168.8.12, I want to block the ssh connection for 8.12, but I want to login from 192.168.8.11. and etc..
How can I do this?
Best Answer
The simplest and best solution would be "Using whatever firewall you happen to be using". Just block access to port 22 from 192.168.8.12 (or specifically only allow it from 192.168.8.11).
If you don't currently have a firewall setup, then you may want to look into
iptables
, which comes as part of the linux kernel. There's a tutorial here. There's also quite a few GUI interfaces for it.The specific command you want to do what you've described above is:
This adds a rule to
INPUT
for TCP traffic aimed at yourssh
port (22), that is coming from 192.168.8.12, and drops it.