Categorized: Apple, Hosting

Using SSH Keys for Password-Free Logins from OS X

If your remote username is different from your OS X username, edit your ~/.ssh/config file like so:

Host whathaveyou.com
    User remote_username

Generating your keys

On your OS X machine, enter this command:

ssh-keygen -t dsa

Enter a password or don’t (I didn’t).

This creates a public (~/.ssh/id_dsa.pub) and private key (~/.ssh/id_dsa).

Copying the public key to the remote server

Log in to the server with ssh (with your password–for the last time).

However you want to do it, open the file ~/.ssh/authorized_keys on the remote server and paste in the contents of id_dsa.pub. Alternately, you could use scp like so:

scp ~/.ssh/id_rsa.pub remote_username@whathaveyou.com:~/.ssh/authorized_keys

(Naturally, if the file and/or folder aren’t there, you’ll have to create them first.)

Now change the permissions:

chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys

All done. The next time you want to ssh to the server, it won’t prompt you for a password.

Sources:

Comments

Nothing to see here yet. Start things off, why don't you?

What do you think about that?

Elsewhere in the empire: Home, Blog, APOD