Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a Mac running Lion at home. I disabled password ssh login; I just want to use public key.

I generated private/public key pair, but now I'm confused. I start a new job tomorrow, and want to login to my home machine from work. Every guide I see says "first copy the (local) public key to the (server) ... using a password."

But how do I do that from a new location if I've disabled password login?

Is there some way to access my home machine from anywhere if I take one of the keys with me?

I thought that if I just copy the home-machine public key into home machine 'authorized_keys', and then use the home-machine private key from my laptop, it would work...

zmbp:~ dzg$ ssh -v
OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /Users/dzg/.ssh/identity type -1
debug1: identity file /Users/dzg/.ssh/id_rsa type 1
debug1: identity file /Users/dzg/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.6
debug1: match: OpenSSH_5.6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
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 '' is known and matches the RSA host key.
debug1: Found key in /Users/dzg/.ssh/known_hosts:6
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/dzg/.ssh/identity
debug1: Offering public key: /Users/dzg/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/dzg/.ssh/id_dsa
debug1: read PEM private key done: type DSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
share|improve this question

2 Answers 2

At the laptop, the SSH client won't automatically pick up a key with a non-default name unless you tell it to. Note that the log says:

debug1: Offering public key: /Users/dzg/.ssh/id_rsa

In other words, it is offering the default key that is ~/.ssh/id_rsa, not the ~/.ssh/home key.

You should either use ssh -i ~/.ssh/home to explicitly specify the key you wish to use. Alternatively, you can rename the home key to id_rsa or id_dsa on the laptop, depending on the actual type of the key.

Also, whenever possible, if you have SSH key authentication problems, find the server-side logs: the server will log the exact reason of the login failure, but won't disclose it to the client, since the client has just failed to prove its identity.

As far as the server knows, the unauthenticated client might be an intruder: no sense giving him/her any more clues than it absolutely has to.

share|improve this answer

Your understanding is corrrect - you don't need to be at a remote location to copy the public key, you could even use sneaker net.

Although you will need to be able to get to the home machine's ssh port.

Some tips on my blog: safe ssh tips

share|improve this answer
so why isn't it working?? I made a keypair on home machine (@, home and ... then I added to home's authorized_keys ... then copied home to laptop's .ssh ... then from laptop tried ssh and ssh -i home (same username) – Ze'ev Jun 4 '13 at 23:17
@Ze'ev What is the filename of the file in the clients ~/.ssh? It will need to be named id_rsa or id_dsa or similar. – ernie Jun 5 '13 at 0:31
@ernie That didn't work either. – Ze'ev Jun 5 '13 at 1:40
Check the logs. Also the .ssh directory should have 700 perms and the files in them 600 perms. – user168261 Jun 5 '13 at 2:23
Permissions are good ... I ran ssh -v -- adding to question above. – Ze'ev Jun 5 '13 at 2:57

Your Answer


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.