top of page
Recent Posts

How to run SSHD server on multiple ports In A Red Hat Enterprise Linux

Updated: Jul 25, 2020

Sometime, we may need to configure the SSHD server in a way so that it can listen on multiple ports. Let do the necessary changes in the SSHD configuration file.

Step:1 To edit the sshd configuration file with our favorite text editor.

# vi /etc/ssh/sshd_config
::::::::::::: CUT SOME OUTPUT :::::::::::::  
Port 22022
Port 22
::::::::::::: CUT SOME OUTPUT :::::::::::::  

Step:2 If SElinux is enabled in enforcing mode, we have set the network port type definitions.

# semanage port -l|grep ssh
ssh_port_t                     tcp      22

# semanage port -a -t ssh_port_t -p tcp 22022
# semanage port -l|grep ssh
ssh_port_t                     tcp      22022, 22

Step:3 To restart the sshd service to reflect the last changes in the configuration file.

# systemctl restart sshd
# systemctl is-active sshd

Step:4 If firewalld service is enabled, we have to configure the firewalld to allow access to the configured sshd ports.

 # firewall-cmd --add-port=22022/tcp --permanent 
 # firewall-cmd --reload 

Step:5 Check if sshd is now running on all the configured ports and verify sshd connectivity from the client systems.

# netstat -atnp|grep sshd
tcp        0      0 *               LISTEN      32599/sshd          
tcp        0      0    *               LISTEN      32599/sshd  

# ss -tlnp | grep 22
LISTEN     0      128          *:22022                    *:*                   users:(("sshd",pid=32599,fd=5))
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=32599,fd=3))
LISTEN     0      128         :::22022                   :::*                   users:(("sshd",pid=32599,fd=6))
LISTEN     0      128         :::22                      :::*                   users:(("sshd",pid=32599,fd=4))
# ssh localhost -p 22022
Last login: Sun Jul 19 21:05:38 2019 from
[root@loadbalancer ~]# logout
Connection to localhost closed.

# ssh localhost -p 22
Last login: Wed Jul 22 22:21:37 2019 from
[root@loadbalancer ~]# 

86 views0 comments

Recent Posts

See All


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page