I have a server with ubuntu installed. After I change the network configuration and restart server, ssh client can't connect server any more. But in the server I can use ssh client to connect itself and the netstat command shows that sshd is listening port 22. And in my computer (win7) ping command is OK to server's new IP.

The configuration in /etc/network/interfaces is:

auto eth0
iface eth0 inet static
address 10.80.x.x
gateway 10.80.x.1

I'm very confused about this. Hope somebody can give me some idea. Thank you in advance!!!

  • Provide ifconfig eth0 print could help here, also see for errors in ssh log (/var/messages in Ubuntu I think) – Alexandre Lavoie Nov 15 '12 at 3:20
  • 1
    Some more things: what you changed the network configuration from and to and also run a tcpdump -n port 22 on the server while trying to connect to it also, use ssh -vvv to connect for more debugging info. – Ladadadada Nov 16 '12 at 16:12
  • It would also be useful to know how your ssh daemon is configured (if it is specifically listening on the old IP address rather than all addresses you need to change that configuration and restart sshd when you change IP addresses...) – voretaq7 Nov 16 '12 at 16:55

Try to connect to ssh daemon using telnet like this:

$ telnet 22

If you got something like this:

Trying 22...
telnet: Unable to connect to remote host: Connection timed out

Then the connection is likely blocked by a firewall or sshd listens on a wrong IP address (check/etc/ssh/sshd_config for a valid ListenAddress option).

In other case it should print something like:

Trying 22...
Connected to 22.
Escape character is '^]'.
SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1

It means your client is able to connect to the server. If you still can't connect to the server with your ssh client then it is likely Windows Firewall blocks the client application.

Also doesn't your ssh client reports any kind of error?


There is no actual question in the "question" here, but I have one answer for the question "How do I get SSH to connect again?"

I ran into this same issue with Lubuntu 14.04 LTS.

I purged ssh with sudo apt-get purge openssh-server and promptly reinstalled with sudo apt-get install openssh-server

I was then able to connect with ssh again.

If you have customized the sshd_config (or any other ssh config file) be sure to make a backup copy in a safe location before purging because a purge removes all config files, where a remove does not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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