Server ssh key login setup [OSX]

Do you ever get fed up of having to enter the ssh password every time you need to access a server from the terminal. Setting up ssh-copy-id is easy and will make your life lazier, oops, easier.

1. Download and install ssh-copy-id using OSX homebrew or via git if you don't have homebrew installed.

sudo brew install ssh-copy-id or just use brew install ssh-copy-id

OR

sudo curl https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/ssh-copy-id.sh -o /usr/local/bin/ssh-copy-id
sudo chmod +x /usr/local/bin/ssh-copy-id

2. Then generate a key, unless you already have a public key.

ssh-keygen -t rsa

3. Then use ssh-copy-id to login and set the key pair on the server.

ssh-copy-id [USERNAME]@[HOSTNAME/IP]

e.g ssh-copy-id simon@192.168.1.1

4. Enter the password you use to login to the server (this is done only once but it has to be done on all the hostnames unless the ssh key file is updated on all hosts).

 

References

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

http://www.jacobtomlinson.co.uk/2013/01/24/ssh-copy-id-os-x/