Ssh hangs without password prompt — works in root or other accounts

mac-osxssh

I had ssh key based login working fine.
Then, I changed the hostname on my computer, and the key based login stopped working.
Seemed to make sense. the keys probably relied on my old hostname.
So, I deleted all of my keys and all the files in ~/.ssh/ and regenerated them (and changed the authorized_keys on the servers I connect to)

Now, any time I try to ssh, it just hangs without the password prompt, no matter where I an trying to ssh to–even servers where I don't have key based login set up. There is nothing in .ssh/config.

Moreover, when I 'su -' to root, ssh works perfectly. no problems at all. This only happens on my user account.

Below is some debugging info from ssh

ssh -vv mylogin@myremoteserver.com
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /Users/myname/.ssh/config
debug1: Reading configuration data /usr/etc/ssh_config
......
debug1: Host 'myremoteserver.com' is known and matches the RSA host key.
debug1: Found key in /Users/myname/.ssh/known_hosts:1
debug2: bits set: 512/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received

And then it just hangs here…..

Here is the dtruss (like strace but for OSX) output near the end where it hangs:
sudo dtruss ssh -vv mylogin@myremoteserver.com

select(0x4, 0x508200, 0x0, 0x0, 0x0)         = 1 0
read(0x3, "$\222\351{L\363\261\25063sN\216\300@q7\203\276b\257\354\337\356\260!{\342\017\271=\222,\245\347t\006\225\257\333;\204\020]\242\005z#\0", 0x2000)  = 48 0
write(0x2, "debug2: service_accept: ssh-userauth\r\n\0", 0x26)       = 38 0
connect(0x4, 0xBFFFEEA2, 0x6A)       = 0 0
write(0x4, "\0", 0x4)        = 4 0
write(0x4, "\v5\004\0", 0x1)         = 1 0
read(0x4, "\0", 0x4)         = -1 Err#4

It seems to be trying ro read something and just hangs on this. If anyone has some suggestions or ideas, I would be very grateful!

Best Answer

The reason your ssh client hangs for your account but not for other accounts (root) is probably because there is something wrong with your ssh-agent. Either that the ssh-agent is not running or that its configuration is wrong in some way.

To have a confirmation of that, you can try the following:

unset SSH_AUTH_SOCK
ssh mylogin@myremoteserver.com

If you're then asked to input the pass phrase to your ssh_key it means you have an issue with your ssh-agent.

See also my post on this related question.