Working on my centos server. Connecting via putty. Changed SSH default port and disabled root login. But the client didn't save the new port and defaulted back to 22 (my new one was 42650 or something like that). So now I can't login/connect to it.
Ssh – Changed SSH default port and disabled root login. Client didn’t save the new port can’t login/connect to it now
loginportputtyrootssh
Related Topic
- Ssh – Putty: ssh root login to server disabled, how i can setup passwordless access to root on server
- Windows – Is the password compromised because I forgot to hit Enter after ssh username
- Linux – Disabling root login with ssh didn’t work
- Centos SSH Access- Changed the SSH port now I cant access server
- Linux – Login problems after changing default port ssh
Best Answer
First, *Bad Admin! BAD! -- You made a change without documenting it.
Hopefully you have learned an important lesson about documenting your changes.
Now, to get out of this mess you find yourself in you have three options:
Connect on the physical console and fix the problem
Per your comments this is a cloud server, so you may not have a physical (virtual) console.
If you have no way of logging in "on the console" this obviously won't work for you.
Port Scan your box with
nmap
and figure out which listening port is SSHPretty straightforward:
nmap -p 1-65535 <target>
like baumgart said.You will get a list of all open ports on the server. Presumably your server is well-configured and you can account for every port that is listening, so the one you can't account for is where SSH is.
(If your server is not well-configured you will have many unaccounted ports - try each of them until you find SSH, then audit your configuration so you know what's listening on your server and what ports should be open...)
Re-Image the system
Since this is a cloud server (again, per your comments) you can wipe it out and rebuild it from your cloud provider's stock image.
Obviously you will have to restore any customizations from your backups if you go this route (you do have backups, right?). If you don't have backups (*Bad Admin! BAD!) and have substantial customizations this may not be a desirable option.