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:
3. Locate The Following Line And Add a New One:
4. Restart SSH Service
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
6. Login Via New SSH Port Then Delete Port 22
Just in case. No one wants to got locked out from his own server.
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.