/ WhatILearned

Installing ssh-keys on Mac OS X

I had to test/build something on our MacBook Air (running stock Mac OS X 10.10.5 Yosemite). This meant I had to check out some code from a repository (source code management server). I like to use ssh-keys because:

  1. More secure: ssh-keys don't transmit "simple" passswords, they use a private-public key-pair system.
  2. Password management is a key management-which loosely translates to file management. You can think of access management to each server as a set of files that are stored (one half (public) on the remote, the other half (private) stored locally). If you ever suspect a compromise you can delete all the remote files and generate new ones.
  3. More convenient: when it comes to logging into remote servers, any time you have more than 1, you don't want to keep typing in your password (and logins) over and over (especially when it comes to source code).

Generating an ssh-key pair is pretty easy (though command-line heavy) on Linux. You simply type:

ssh-keygen

and the prompts will take you through the rest of the way. If need be, it's highly recommended that you put the key files into ~/.ssh directory (if it doesn't exists, make one using mkdir ~/.ssh).

On the Mac OS X. You need to not only type ssh-keygen but also ssh-add -K LOCATION_PRIVATE_KEY_FILE. These commands are done in terminal.

This is because Mac OS X uses a different mechanism to store/retrieve the ssh keys. So the ssh keys mac os location doesn't have to be in ~/.ssh it's completely managed by the system.