Skip to content

Instantly share code, notes, and snippets.

@trey
Created May 18, 2012 03:22
Show Gist options
  • Save trey/2722974 to your computer and use it in GitHub Desktop.
Save trey/2722974 to your computer and use it in GitHub Desktop.
Using SSH Keys for Password-Free Logins From OS X

Probably not the best way to do things these days.


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

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

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

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_rsa.pub. Alternately, you could use scp like so:

scp ~/.ssh/id_rsa.pub [email protected]:~/.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:

@trey
Copy link
Author

trey commented May 18, 2012

former location

This is a Solutions Log post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment