Select Page

How to Change default SSH Port 22 in Linux
July 14, 2017

The standard port used by SSH service is 22/TCP. However, you might want to change SSH default port 22, in order to make sure your server is as secure as possible through obscurity because the standard 22/TCP port is continuously targeted for vulnerabilities by hackers and bots in internet.

1. Connect To Your Server Via SSH As Root User

2. Run the following command:

 vi /etc/ssh/sshd_config

3. Locate The Following Line And Add a New One:

# Port 22
# Port 23456

4. Restart SSH Service

/etc/init.d/ssh restart
or
/etc/init.d/sshd restart
centos 7
systemctl restart sshd.service

5. Update Your Firewall Settings

iptables
iptables -I INPUT -p tcp --dport 23456 -j ACCEPT
systemctl restart iptables.service
firewalld
firewall-cmd --zone=public --add-port=23456/tcp --permanent
firewall-cmd --reload

6. Login Via New SSH Port Then Delete Port 22

Just in case. No one wants to got locked out from his own server.

* Conclusion

In this tutorial, you have learned how to change the SSH port on your Linux server.

If you have any questions or feedback, feel free to leave a comment.

Related Articles

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This