0

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?

0

2 Answers 2

4

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:

# iptables -A INPUT -p tcp --dport ssh -s 192.168.8.12 -j DROP

This adds a rule to INPUT for TCP traffic aimed at your ssh port (22), that is coming from 192.168.8.12, and drops it.

1

If you have tcpwrappers installed, then you can put an entry in to hosts.deny. Read the man page for hosts.deny for details.

You must log in to answer this question.