Abel Melquiades Callejo asked:
Allow the following TCP port numbers on SSH server
- The machine uses an Amazon Linux AMI distribution
- The SSH installation is based on an SELinux system
By default, SSH uses TCP port
22. Is it possible to allow the SSH server to accept inbound traffic from TCP port
2222? If so… How?
I looked at the SSH’s config file…
... # If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # #Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: ...
It tells that I should use
semanage to configure this section instead of overwriting the said file.
How to use
semanage to allow the SSH server to accept inbound traffic from 2 TCP port numbers mentioned above? Also both at the same time.
This comment means that you must do both.
You must specify all of the desired
sshd_config, and you must also run
semanage as shown if you wish to add any ports other than 22.
Port 22 Port 2222
Then you would run
semanage port -a -t ssh_port_t -p tcp 2222
After doing both of these, it is safe to restart OpenSSH.
systemctl restart sshd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.