SSH Keys

Generating SHH Keys

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/<user>/.ssh/id_rsa):

enter path or press return for default

Enter passphrase (empty for no passphrase):

Entering a passphrase is highly recommended unless you are SURE that your computer with private key is secure (so enter a passphrase)

Enter same passphrase again:

This is pretty self explanatory

Enter same passphrase again:
Your identification has been saved in /Users/<user>/.ssh/id_rsa.
Your public key has been saved in /Users/<user>/.ssh/
The key fingerprint is:
4e:2a:f9:df:04:bd:d1:01:8f:b1:87:8f:26:60:5a:1e <user>@<computer>
The key's randomart image is:
+--[ RSA 2048]----+
|        o        |
|         B     B |
|    E   + +      |
|   = o   * .     |
|  . . . S =      |
|     . * . o     |
|    o . . o      |
|     o   o  .    |
|      ... .      |

Congrats, you have now generated an ssh key

Using the ssh keys

SSH Keys can be used for multiple things but we mostly use them for two things git and password-less remote login

Remote Login

Assuming you used the default options (for path), you first have to upload the the public key to the remote server.
NOTE: you need to send the .pub file, not the other file
The .pub file can either be sent through email, uploaded through AFP, scp or whatever you prefer (we’ll assume scp in this tutorial)

cd ~/.ssh
scp <user>@<computer>:.

Once the file is upload you need to ssh into the computer and run the following:

mkdir .ssh
cat >> .ssh/authorized_keys

Congratulations you now have password-less ssh login

Using the key for git

Simply email the .pub file to me and i’ll upload it (Thomas Cool)