Today we will learn how to change the SSH port? The default SSH port on all operating systems is port 22 For security measures.
How to change the SSH port?
The server’s SSH configuration file is located at: /etc/ssh/sshd_config
- SSH into your server as the root user > ssh root@<ip address> -p 22
- Open the configuration file with your favorite text editor. (Nano -c in this example. The -c flag shows line numbers.) > nano -c /etc/ssh/sshd_config
- Line #13 shows the currently configured port number. (ie port 22) means, SSH is currently using 22
- Change the numeric digits from 22 to your desired port number, for this example we will use 2222
- After changing to your desired port, press [CTRL] + X to save the changes. You will be prompted, [ carefully read the massage ]”Save the modified buffer (answering “no” will destroy the changes)?” Press Y and then press [Enter].
- You will be prompted again, “Name of file to write: /etc/ssh/sshd_config”, this time just press [Enter].
- Restart the SSH daemon: > /etc/init.d/sshd restart > You should see that it was stopped and started successfully: Stopping sshd: [ OK ] > Starting sshd: [ OK ].
- For good measure, let’s make sure the changes are made and that it’s running properly.
# netstat -tulpn |grep sshd
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 5672/sshd
tcp 0 0 :::2222 :::* LISTEN 5672/sshd
- 2222 shows that it is now listening correctly on 2222 instead of 22.
Now it’s time to connect to your server using the newly configured port number. If you want to know how to fix the SMTP 530 Error then you can read this article. You can buy SMTP service from Oudel Inc.



