Knowledge Base

(AlmaLinux) How to Change SSH Port

Open server console and login as root user, or open SSH and login as an existing user with root privileges

Open the SSH configuration file using a text editor:
nano /etc/ssh/sshd_config

Find the line '#Port 22', change it to your preferred port number (e.g., 2222), and save the file.

Allow the new port through SELinux:
semanage port -a -t ssh_port_t -p tcp 2222

If you have a firewall enabled, open the new port:
firewall-cmd --permanent --add-port=2222/tcp
firewall-cmd --reload

Restart the SSH service to apply the changes:
systemctl restart sshd

If you have Premium OS support from us, we can configure the Firewall for you.

Please rate this article to help us improve our Knowledge Base.

0 0