How to change SSH Port on Linux VPS
Posted about 5 years ago 2.6kThis tutorial will provide you a few simple steps on how to change your server's SSH port from default 22 to any other port. This is highly recommended in order to increase your server security. Please take a note, that new port number should not be used by other service or blocked by your server firewall rules.
Changing SSH Port On CentOS, Debian , Ubuntu
.Login to your Linux VPS via SSH as root user. You can do it via terminal/shell or use SSH client, for example
Copy the command:
vi /etc/ssh/sshd_config
Find the line with information: # Port 22
Remove the #
symbol and change "22" into your wanted port number.
Save and exit the file (Press "Esc" then enter :wq
).6. Restart your sshd service by running command bellow:
For CentOS 6, Debian 8, Debian 9:
service sshd restart
For CentOS 7:
systemctl restart sshd.service
For CentOS 7:
systemctl restart sshd.service
For Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04:
service ssh restart
From now on, you will be able to connect via SSH using your newly updated port number.