Change SSH port 22


#1

Hi all,

I want to change the standard SSH port, when editing the sshd_config file you can read that this has to be done through the registry configuration. Indeed when I change the port that way and reload the service a cat /etc/ssh/sshd_config shows the new port setting.
However, when i use the new SSH port I get the Connection refused error, this also with the now defunct standard 22 port.
What am I overlooking?


#2

Hey,

first make sure that your sshd is actually running and which port it’s really listening on. This can be done in multiple ways, e.g.

lsof -PniTCP -sTCP:LISTEN | grep sshd

If it’s really running and listening on the port you want it to then you’ll have to check your firewall next. See the output of the following:

iptables -L INPUT -nv

My guess is that your firewall is running and opening port 22, but not the new port. You’ll have to set that up yourself, e.g like this:

ucr set security/packetfilter/tcp/<your-port-number>/all=ACCEPT

Kind regards,
mosu


#3

Mosu thanks a lot,

You where correct, forgot that last step and now it is working.

Regards,
Jos.