How to Change SSH Port in Ubuntu 24.04

SSH (Secure Shell) is a network protocol used to securely access and manage a server remotely. By default, SSH uses port 22. To enhance security, we can change the default SSH port to a different port number that is less commonly used. Changing the SSH port can help reduce the risk of brute force attacks or automatic port scanning.

Steps to Change SSH Port

Open the ssh.socket configuration file:

For example, change the port from 22 to 2404:

Then reload the daemon:

Open the sshd_config configuration file:

Change the line #Port 22:

Then restart the ssh service:

Check the service status to see if ssh is using the new port:

SSH Service Status
SSH Service Status

If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!

Donate via PayPal: https://paypal.me/musaamin

Leave a Reply

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