By default, most of the web server’s SSH port is
22 such as AWS, Digital Ocean. By changing the SSH port of any Linux server, you can tighten the security of the server. In this, tutorial, I am going to change SSH port in Linux easily.
Change SSH Port in Linux Easily
You can easily change SSH port in Linux systems. You can use ports ranging from
0 to 65535. The port number 0 is reserved and cannot be used. The default SSH service listen on
port 22. Just this port with some other ports.
To change and update SSH port, edit OpenSSH configuration file
$ sudo vi /etc/ssh/sshd_config
In the configuration file, search for
port 22 . When you find port 22, uncomment the port and replace it with some other nonstandard port (let’s take 2220.) Now save the config file.
Now, restart the SSH daemon to apply changes.
$ sudo systemctl restart ssh
Awesome, your ssh server login port has been changed successfully.
Access the Server with New SSH Port
As the SSH daemon is running under non-standard port, you have to mention port number with the command-
$ ssh -p 2220 user@serverIP
In this short tutorial, you have learned to change SSH port in linux. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle