How to change your SSH port

Please follow the steps listed below as-is

nano /etc/ssh/sshd_config

Find, the line line which states 'Port 22'. Make sure that you pick a port which is currently not used on the system.

Change it to reflect the following and replace with your desired SSH port.

Port <SSH port Here>

Save the file and then,

service sshd restart

Next time you wish to SSH into your VPS/Server you'll have to select the port you set it to,

ssh username@hostname.com -p <SSH port Here>

Updating your firewall config

You can change the number "22" in the commands listed below to the new port you've set above and then run the command.

For UFW Firewall

Used primarily on Ubuntu based systems

 ufw allow 22

firewalld

firewalld is primarily used on CentOS 7

 firewall-cmd --zone=public --add-port=22/tcp --permanent
 firewall-cmd --reload

For iptables

Most commonly used firewall on most systems (CentOS 6, Debian)

iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
service iptables save
service iptables reload

CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS