2

This is for specified source:

iptables -A INPUT -p tcp --dport ssh -s 10.10.10.10 -j DROP

how to do this for all incoming ssh requests?

JoKeR
  • 6,972
  • 9
  • 43
  • 65
jack
  • 21
  • 1
  • 2

2 Answers2

2

There are 2 easy ways to stop someone from being able to ssh to a machine.

1st. with iptables leave off the -s option. That denotes the source. if you use sudo iptables -A INPUT -p tcp --dport ssh -j DROP that will block all connections to port 22.

2nd. as mentioned int he comments stop and disable the openssh-server. There are several ways to do that.

You can uninstall openssh-server,

rename the init.d/ssh.conf,

run update-rc.d ssh disable, or

use the method https://askubuntu.com/a/56849/295286

grag42
  • 226
  • 1
  • 6
0

Provided ufw is install, you can type the following on the terminal:

sudo ufw enable
sudo sudo ufw deny ssh

To check if the firewall is active:

sudo ufw status

You can also block the port ssh is using:

sudo ufw deny 22/tcp

To delete the rule if you don't need it any more:

sudo ufw delete deny ssh

Reference Link

Harris
  • 2,598