Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I just upgraded to Lion and find now that my ssh keys are not working properly when trying to log into various servers via SSH.

I've checked permissions on the ~/.ssh directory and the ~/.ssh/authorized_keys file, and they are properly set to 0700 and 0600 respectively.

What can I do to fix this issue?

Here is a sample of the ssh connection process:

$ ssh -v 70.32.90.120
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/gonzo/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to 70.32.90.120 [70.32.90.120] port 22.
debug1: Connection established.
debug1: identity file /Users/gonzo/.ssh/id_rsa type -1
debug1: identity file /Users/gonzo/.ssh/id_rsa-cert type -1
debug1: identity file /Users/gonzo/.ssh/id_dsa type -1
debug1: identity file /Users/gonzo/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '70.32.90.120' is known and matches the RSA host key.
debug1: Found key in /Users/gonzo/.ssh/known_hosts:61
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/gonzo/.ssh/id_rsa
debug1: Trying private key: /Users/gonzo/.ssh/id_dsa
debug1: Next authentication method: password
gonzo@70.32.90.120's password:
share|improve this question
1  
Are you sure that it's a client-side problem and that nothing has changed on the server? I had 0 problems with ssh after my upgrade to Lion. –  Jason Salaz Jan 30 '12 at 17:38

2 Answers 2

Ask your administrator to look at the sshd log. Or more likely you will need to ask them to run a second instance of sshd on a secondary port with debug turned on, doing this should tell you what the key error is.

sshd is quite a bit tricky when it comes to this, for good reason. On the server you are ssh'ing to, the administrator will have to run a command such as /usr/sbin/sshd -d -p 2222

When running sshd in debug mode, it will handle the first connection, spew out lots (and I do mean lots of output), and then terminate the server. Issuing -p means run the server on port 2222, which is necessary because it can't take over the default port of 22 where the server is normally running.

You will then have to run ssh -p 2222 70.32.90.120 (you don't need -v in this instance). The server's logs should then give you the exact reason that your private key is being rejected from the server. Note that this exchange may need to occur multiple times, because ssh is very stringent when it comes to security, and you may find multiple failures in the process.

share|improve this answer

I would start with one of the following:

  • distributing the new keys
  • re-load the old keys from a backup and do the work to ensure Lion server is actually using the old keys.

The former always seems like more work initially, but I find it to always be faster than the latter. ymmv

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.