Select Page

How To Change Default Ssh Port 22 In Linux
Posted on July 14, 2017
How To Change Default Ssh Port 22 In Linux

Jackie, also known by his nick-name KK, always strives for the best and learn from the best. Working and living as a Freelance Web Engineer/ Web Developer & Designer/ Amateur Youtuber/ Husky Lover. If you love one of these things that I love, we already have something in common.

Jackie Sung

Owner

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