SSH public key authentication

First posted on the 16th July, 2012 – IT
Last modified on the 1st November, 2013, at 12:17 pm

SSH public key authentication is used to establish ssh connection without the need to type a password. The details have be covered very well by many many other people like this. This post is just to remind me how to do it!

This process will allow the establishment of an SSH connection from client to server without a password. Remember you push your public key identity to the server to allow the server to verify your identity.

  1. on client create ~/.ssh directory with permission 700
  2. on client create public and private key pair with passphrase
    client:~> ssh-keygen -q -f ~/.ssh/id_rsa -t rsa
  3. transfer public key from client to server
    client:~> scp ~/.ssh/id_rsa.pub user@server.example.com:~
  4. on server add public key of client to authorisedkeys file
    server:~> cat ~/id_rsa.pub >> ~/.ssh/authorized_keys2

Follow process in reverse to allow password free authenitication from server to client.

Remember to use a real passphrase, and get OS X to remember the passphrase in your keychain (dialogue will spring up when you first try and connect).