I am trying to SSH into a server and it hangs at login. This is the output of ssh -v:

OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to $$$$$$ [888.888.888.888] port 22. 

I have generated ssh-keys on the client and placed its public key (id_rsa.pub) in the host's authorized_keys.

All machines are connected with a physical cable, not wireless. I can successfully ssh from the client to another separate machine on the same network, and I can also ssh from that separate machine to the host successfully. Finally I am able to SSH from host to client. But when I try to SSH from client to host it hangs.

What could be the issue?

2 Answers

Take a look at this blog post: “Troubleshooting sshd server configuration.

Especially the part,

  1. run /usr/sbin/sshd -d -D -p 222 on the server.
  2. run ssh -v -C -A -X -p 222 on the client.

Normally the log on the server side will reveal what went wrong.

I had the same issue (on MacOS), but did not have the option to run anything on the server side as the accepted answer suggests. I went through many troubleshooting steps (see below), and in the end it seems like I have some DNS issue which is blocking the connection to the port, and for some reason I am not getting a Could not resolve hostname error. IT support confirmed that none of my login requests were coming through to the host.

Eventually what worked was to run nslookup server.domain-name.de to find the IP address. It returns:

Server: XXX.XXX.XXX.XXX Address: XXX.XXX.XXX.XXX#XX Name: server.domain-name.de Address: XXX.XXX.XX.XXX 

Using the second Address, I tried logging in again as follows: ssh which worked fine!

Other troubleshooting steps which did not work for me but might work for others:

  • In System Preferences > Sharing, check that Remote Login is enabled for all users
  • Use the Network Utility app (easily found through Spotlight with CMD + Space, Network Utility) enter the server domain name and scan for open ports. This told me that port 22 was indeed open.
  • I went to ~/ssh/ssh_config and added GSSAPIAuthentication no to the uncommented options in the lines below Host *.
  • I restarted my MacBook, checked my firewall was off, and tried on a VPN.
  • I tried ssh localhost, which worked. I tried to connect to a different server, but had the same problem of being stuck on connecting to port 22.
  • And of course I checked that my username was spelled correctly.
  • Once we figured out it was likely a DNS issue, we tried flushing the DNS cache:
    sudo killall -HUP mDNSResponder sudo killall mDNSResponderHelper sudo dscacheutil -flushcache 
    but this didn't fix the issue for me.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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