SSH (Secure Shell) is a vital service for managing remote servers, but the default settings can make your system vulnerable to brute force attacks. This guide explains how to change the SSH port and secure it with a strong password on CentOS 8, AlmaLinux 8/9, Rocky Linux 8, and Ubuntu 22.04.
sudo
privileges.Edit the SSH configuration file:
Look for the following line and change the port from 22 to a non-standard port (e.g., 2222):
Uncomment the line and set your desired port:
Save and exit the editor (Ctrl + O
, then Enter
, and Ctrl + X
).
Restart the SSH service:
Test the new SSH port before logging out:
Set a Strong Password for Your User:
Use the following command to change the password for your user:
Stay Updated! Join Our Channels for the Latest News and Notifications
Stay connected with us on social media!
Sign up for our newsletter to receive the latest updates, tips, and exclusive offers for improving your email marketing campaigns!