How do I associate an ssh public key with a user account on the machine I connect to, so I don't have to type in the account password every time I make an ssh connection to that machine?

The machine being connected to is an older mini with Leopard installed. I assume that this is doable in Leopard, and I don't have to upgrade to Snow Leopard or Lion.

2 Answers 2


First, you create a public and private key (if you haven't done so already) on the machine from which you want to login:

ssh-keygen -t dsa

You only need to do this if there isn't already a ~/.ssh/id_dsa.pub file.

On Linux, there's the ssh-copy-id helper. On Mac, you need to copy the public key by hand:

  • Copy the generated public key to the target machine:

    scp ~/.ssh/id_dsa.pub user@targetmachine:myPublicKey.pub

  • Login to the target machine:

    ssh user@targetmachine

  • Append the public key to the authorized keys:

    cat myPublicKey.pub >>.ssh/authorized_keys

  • You can now delete the copied key:

    rm myPublicKey.pub

  • Done. You should now be able to login to your target machine without the need to enter a password.

  • If you have never set up an authorized_keys on the remote host, you can save a little bit of time by simply doing; scp ~/.ssh/id_dsa.pub user@remotehost:~/.ssh/authorized_keys Commented Aug 15, 2011 at 20:02
  • 1
    @VxJasonxV: Right, but now that I think about it there's even a way to collapse all the bullet-points into one line, even with appending: ssh user@targetmachine 'cat >>~/.ssh/authorized_keys' <~/.ssh/id_dsa.pub But I think the step-by-step solution in my answer is easier to understand.
    – DarkDust
    Commented Aug 15, 2011 at 21:35
  • It is, by far :). Commented Aug 16, 2011 at 0:37

You should have an id_dsa.public file in your ~/.ssh folder.

Just copy that file over to the server, into ~/.ssh folder and append its contents to the authorized_keys file.

Your next login should be automatic. It can be that you're asked about the password you used to created the private key, but there's an option to store that password into your keychain.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .