• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Monday, May 12, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Change SSH Port and Open Firewall on AlmaLinux: A Step-by-Step Guide

in Almalinux, Linux OS
How to Change SSH Port and Open Firewall on AlmaLinux

SSH is a network protocol that allows secure remote access to a server or computer. By default, SSH uses port 22 for connections. However, using the default port can make your server vulnerable to attacks. Therefore, it’s a good practice to change the default SSH port to a non-standard port to increase security. Additionally, it’s important to open the new port in the firewall to ensure that incoming traffic on the new port is allowed. In this blog post, we will discuss how to change the SSH port and open the new port in the firewall on AlmaLinux.

Step 1: Log in to your AlmaLinux server

First, log in to your AlmaLinux server as a user with sudo privileges.

Step 2: Open the SSH configuration file

Next, open the SSH configuration file using a text editor such as nano or vim. The SSH configuration file is located at /etc/ssh/sshd_config. Use the following command to open the file in nano:

sudo nano /etc/ssh/sshd_config

Step 3: Change the SSH port

Find the line that specifies the SSH port, which is usually near the top of the file. The line should look like this:

#Port 22

Uncomment the line by removing the # symbol at the beginning of the line, and change the port number to the desired value. For example, if you want to use port 2222, the line should look like this:

Port 2222

Step 4: Save the changes

After making the changes, save the file and exit the text editor. In nano, you can save the file by pressing Ctrl+X, then Y to confirm the changes, and Enter to save the file.

Step 5: Open the new SSH port in the firewall

To open the new SSH port in the firewall, use the following command:

sudo firewall-cmd --add-port=2222/tcp --permanent

This command adds a new rule to the firewall configuration to allow incoming traffic on port 2222/tcp. The --permanent option makes the rule persistent, so that it will survive a firewall service restart.

Step 6: Reload the firewall configuration

After adding the new rule, reload the firewall configuration to apply the changes:

sudo firewall-cmd --reload

Step 7: Restart the SSH service

Finally, restart the SSH service to apply the changes:

sudo systemctl restart sshd

Verify that the SSH service is running on the new port by attempting to connect to the server using the new port number. For example, to connect to the server using port 2222, use the following command:

ssh user@server_ip_address -p 2222

Conclusion

Changing the default SSH port and opening the new port in the firewall are simple but effective ways to improve the security of your AlmaLinux server. By following the steps outlined in this blog post, you can easily change the SSH port to a non-standard value and add a new firewall rule to allow incoming traffic on the new port, making it more difficult for attackers to find and exploit your server.

How to Change the SSH Port on Ubuntu Server

ShareTweet
Previous Post

ESXi Troubleshooting with CLI: How to Diagnose and Resolve Common Issues Using Command Line

Next Post

How to Change the SSH Port on Ubuntu Server: A Step-by-Step Guide for Better Security

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

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

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.