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,22Finally, reload or restart the OpenSSH server, enter:
# /sbin/service sshd reload
Verify, sshd is listing on TCP port # 1255, enter:
# netstat -tulpn | grep 1255
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 6 comments… read them below or add one }
I think it’s throwing you permissions error but not the other way..
If you’re changing the port to 1255, you should really remove the allow statement for port 22.
semanage port -d -t ssh_port_t -p tcp 22
i’ll double that as well…
Thanks, I was thinking exactly the same.
I’m on CentOS 6.2, and I can’t remove Port 22 as per the instructions above — SElinux complains that port 22 is part of the ‘policy’ and can’t be removed. How do I fix this?
Actually, I’ve spoke to soon and have encountered this as well.