Select Page

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

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
/etc/init.d/sshd restart
centos 7
systemctl restart sshd.service

5. Update Your Firewall Settings

iptables -I INPUT -p tcp --dport 23456 -j ACCEPT
systemctl restart iptables.service
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.

By Jackie Sung

Jackie Sung, 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.

Related Articles

How To Install and Configure Proxmox VE on Hetzner Server

How To Install and Configure Proxmox VE on Hetzner Server

Proxmox VE is a complete open-source platform for enterprise virtualization. With the built-in web interface you can easily manage VMs and containers, software-defined storage and networking, high-availability clustering, and multiple out-of-the-box tools on a single solution.

read more


Submit a Comment

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

Pin It on Pinterest

Share This