How to restrict ssh and ftp to certain ip address?
By Emma Johnson •
What is the easiest way to make it so that the only way anyone could access the ssh or ftp for my ubuntu machine is to be on a certain ip address?
12 Answers
Ubuntu Firewall (ufw).
See if Ubuntu Firewall is active:
$ sudo ufw statusIf it's inactive, enable it:
$ sudo ufw enableAllow SSH connections from a specific IP address:
$ sudo ufw allow from 123.123.123.123 to any port 22 proto tcpAllow FTP connections
$ sudo ufw allow from 123.123.123.123 to any port 21 proto tcpView firewall rules:
$ sudo ufw statusDelete above SSH rule:
$ sudo ufw delete allow from 123.123.123.123 to any port 22 proto tcpDisable Ubuntu Firewall:
$ sudo ufw disable 5 The easiest way is using the firewall. DigitalOcean has a great tutorial on configuring ufw.
First make sure ufw is enabled, if not enable it:
sudo ufw status
sudo ufw enableThe relevant command for ssh/ftp from one address would be
sudo ufw allow from 15.15.15.15 to any port 22
sudo ufw allow from 15.15.15.15 to any port 21Port 22 is the defaut for SSH, 21 is the default for FTP. You can replace 15.15.15.15 by either a subnet you want or a specific IP.
More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"