Ssh – Can’t set SSH port to something other than 22

iptablesssh

When I try to set my SSH port to something other than 22 (editing /etc/sysconfig/iptables and /etc/ssh/sshd_config) I end up locked out of my server and having to boot into rescue mode to rectify the problem.

I've gone through this cycle a few times now, each time being more careful that I'm doing the right things.

Is it possible that my new port (33933 in this case) is somehow being blocked somewhere else – or there's another file referencing 22 that I need to change?

This is on CentOS 6 on a brand new dedicated box that I've just set up from oneprovider.com (an online.net reseller).

Best Answer

You can set ssh to multiple ports. Just had multiple Port lines, eg

    Port 22
    Port 1500

That way you can can port 22 still working while you troubleshoot port 33933.

Next after you changed your config and restart ssh (you can restart ssh with an active connection), would be to test the server is listening on that port.

    netstat -ltnp

Post the output of that.