Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
1  
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 at 4:03
    
I'm quite new to this. Walk me through what you are talking about? –  Ovaryraptor Feb 19 at 4:10
    
The server is hosted on cloudatcost so it's not physically here. –  Ovaryraptor Feb 19 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 at 6:10
1  
Just login from the console and fix it. –  Michael Hampton Feb 19 at 18:43

2 Answers 2

up vote 5 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 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 at 3:17

Because you are on Windows, you'll need to download the nmap utility: http://nmap.org/download.html

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

 
discard

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.