Posted by & filed under Internet, Unfiled.

A few days ago I tried to change the SSH port of a server I’m working on from 22 to something different since that’s supposed to help with security. But the port I changed to was blocked by the firewall which means that after a reboot I had effectively locked myself out.

The server had WHM / cPanel on it so I was still able to manage the server, but needed to get back SSH. Fortunately cPanel has a built in script for this mistake.

Put the following into your browser replacing with the domain name of your server.

Presto. SSH will be back on port 22. One thing you’ll need to do is go back and fix /etc/ssh/sshd_config so that it’s back on port 22 as well. I found out this morning that this fix doesn’t actually change the config file.

Leave a Reply

Your email address will not be published. Required fields are marked *