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.

I followed step one of this guide to change the SSH port of my server: http://www.linux.com/archive/articles/61061

Now, when I try to log in to it again by typing

    ssh -p 1234 user@my-server

I get the message

    Connection closed by xxx.xxx.xxx.xxx

xxx being the IP address of my server. Not using the -p option of using any other port results in the answer

    ssh: connect to host my-server.com port xxx: Connection refused

How can I connect to it again? It's a Debian machine, in case that matters.

share|improve this question

migrated from stackoverflow.com Oct 13 '09 at 0:18

This question came from our site for professional and enthusiast programmers.

    
Not ap rogramming question, superuser.com perhaps? –  Kurt Oct 13 '09 at 0:06
    
Is there a firewall involved? –  Sinan Ünür Oct 13 '09 at 0:06
1  
@Kurt I think ServerFault is more appropriate here because we are dealing with sshd and possibly a firewall. –  Sinan Ünür Oct 13 '09 at 0:07
1  
To debug ssh use -v -v -v -v -v -v –  delete Oct 13 '09 at 0:10
1  
For future reference, after you make any change to an important service like sshd, ensure that you establish a new session successfully before you close the current session. Restarting sshd does not affect existing ssh sessions, so if you've screwed it up you still have an active session to fix it. If you don't follow this practice, you'll probably going to have to get console access (which may require physical access depending on the hardware) to fix the problem. –  James F Oct 13 '09 at 7:15

3 Answers 3

up vote 2 down vote accepted

(As Kurt just mentioned) After having changed your default port in sshd_config, did you follow up by ensuring iptables was allowing inbound connections to your new port?

share|improve this answer
    
Don't post non-answer answers. –  Sinan Ünür Oct 13 '09 at 0:09
1  
Telling someone to verify their their firewall is open IS an answer. The phrasing used here is just a bit indirect... –  Zoredache Oct 13 '09 at 0:21
    
Most likely this is the answer, that the server does not allow any inbound connections on that new port. Is there ANY chance I can get access to it? (physical access is not possible) –  Manuel Meurer Oct 13 '09 at 18:21

Did you open a hole in the firewall?

share|improve this answer
    
Don't post non-answer answers. –  Sinan Ünür Oct 13 '09 at 0:08
    
Don't be a jackass, that likely is the answer. –  phoebus Oct 13 '09 at 3:21

First of all, ensure that SSH is indeed running on the new port. On the server machine, run

netstat -untap

Check that sshd is listening on port 1234.

Next, check that there are no firewall rules blocking port 1234 anywhere along the network between your client machine and the server (including on the client and the server). By default, your Debian firewall rules should be clear unless you have changed them. However, if there is any other network device sitting between your client and server, it can still block that port.

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.