Change OpenSSH Port To 1255 ( SELinux Config )

I’ve edited /etc/ssh/sshd_config to change the port number:

Port 1255

However, I’m getting an error as follows:

sshd[26792]: error: Bind to port 1255 on 192.168.1.100 failed: Permission denied

How do I change default OpenSSH port number from 22 to 1255 under RedHat Enterprise Linux server version 6 and SELinux?

By default SELinux only allows port number 22. To display current port contexts, enter:
# semanage port -l | grep ssh
Sample outputs:

ssh_port_t                     tcp      22

To add port 1255 to port contexts, enter:
# semanage port -a -t ssh_port_t -p tcp 1255
You can verify new settings, enter:
# semanage port -l | grep ssh
Sample outputs:

ssh_port_t                     tcp      1255,22

Finally, reload or restart the OpenSSH server, enter:
# /sbin/service sshd reload
Verify, sshd is listing on TCP port # 1255, enter:
# netstat -tulpn | grep 1255

Source

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s