Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
I would run nmap against the box, telling it to check all open ports. That should tell you what ports are open, and i think it would tell you which port you need. Something like 'nmap -p 1-65535 <target>'. – baumgart Feb 19 '14 at 4:03
I'm quite new to this. Walk me through what you are talking about? – Ovaryraptor Feb 19 '14 at 4:10
The server is hosted on cloudatcost so it's not physically here. – Ovaryraptor Feb 19 '14 at 4:25
I figured out your suggestion baumgart. Unfortunately the ranges that it would be in are all unknown although it also says Not shown: 108 closed ports so I don't know what to make of that. – Ovaryraptor Feb 19 '14 at 6:10
Just login from the console and fix it. – Michael Hampton Feb 19 '14 at 18:43
up vote 6 down vote accepted

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:

  1. 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.

  2. Port Scan your box with nmap and figure out which listening port is SSH
    Pretty 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...)

  3. 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.

share|improve this answer
Got it to work with #1 and #2. (with some help from cloudatcost :D) – Ovaryraptor Feb 21 '14 at 17:31
...and you now have a pen and a yellow legal pad (or stack of post-it notes) to scribble changes on as you're making them, right? :-) – voretaq7 Feb 22 '14 at 3:17

Because you are on Windows, you'll need to download the nmap utility:

In the COMMAND field, type in: nmap -T4 Aggressive -A -v -f -p 1-65535

This can be a very long scan, upwards of 30 minutes to complete, but it will give you the most detailed output for any unresponsive SSH ports that might be available.

If you see a port that appears to be SSH, you can try using Putty to connect to it. I would select a verbose output option to get more information from it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.