The SSH protocol operates on port 22 by default. In order to accept incoming connections on your Red Hat 7 Linux SSH server, you will need to ensure that port 22 is allowed through the firewall. This will involve opening the port in firewalld, the default firewall interface for Red Hat.
In this tutorial, you will learn how to open SSH port 22 on Red Hat Enterprise Linux version 7. The only prerequisite is that you must already have SSH installed.
In this tutorial you will learn:
- How to open SSH port 22 on RHEL 7
- How to view configured firewall rules in firewalld and iptables
|Category||Requirements, Conventions or Software Version Used|
|System||Red Hat 7 Linux|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to open SSH port 22 on Red Hat 7 step by step instructions
- Start by opening a open a command line terminal. Then, execute the following command to open SSH port 22 on your Red Hat 7 Linux server:
# firewall-cmd --zone=public --permanent --add-service=ssh
- To apply your new firewall settings you need to reload firewalld:
# firewall-cmd --reload
- You can verify the new change by listing all configured rules for firewalld:
# firewall-cmd --list-all
Alternatively check the
# iptables-save | grep dport\ 22
- In case you need to remove this rule later, thus closing SSH port 22 again:
# firewall-cmd --zone=public --remove-service=ssh --permanent # firewall-cmd --reload
In this tutorial, we saw how to open SSH port 22 on a Red Hat 7 Linux system. After making this change, your system will begin to accept incoming SSH connections. Of course, you may still need to configure other security devices, such as a physical firewall or router that sits in front of your Red Hat server.