0. Install Nano
In some minimal versions of RockyLinux or AlmaLinux, nano may not be pre-installed, which is required to access system files.
dnf install nano -y
1. Open Server SSH
Open your server's SSH Command Shell and log in as root user.
2. Open the SSH Configuration File
Open the SSH daemon configuration file using a text editor like nano:
nano /etc/ssh/sshd_config
2. Locate the Port Directive
Scroll through the file until you find the line that specifies the port. It usually looks like this:
#Port 223. Change the Port Number
Remove the
# symbol to uncomment the line, and change 22 to your desired port number (ensure it is a port not being used by another service, typically between 1024 and 65535).3. Save and Exit
Save the file and exit the text editor (in nano, press
Ctrl+O, hit Enter, then Ctrl+X).4. Update Your Firewall
If you have a firewall set up on your server, it is important you update your new port onto the firewall before restarting your SSH.
5. Restart the SSH Service
Apply the changes by restarting the SSH:
systemctl restart sshd