parm530
11/8/2017 - 3:16 PM

SSH Folder

Setting up a .ssh folder and what goes inside

Create an .ssh folder in ~

  • Using Github, SSH is used to provide authentication for pulling and pushing code.
  • Any one can clone a repo, but SSH is used to provide extra security.

Create keys for the domain you will be authenticating with.

  • Quick google search or example using github is:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  • This can work with just ssh-keygen, but the extra arguments are used for security.
  • It will then prompt you to name your keys, otherwise the default name will be id_rsa
  • This is hard to remember, so give it a name that makes sense: github
  • You can enter a passphrase, but you must remember it!
  • Next, cat name.pub (github.pub) to obtain the actual key value. The .pub is the public key you are sending over.
  • Go to github->settings->SSH to add the ssh key.
  • In the terminal, check to see if the keys are working. To do this run the command:
ssh -T git@github.com
  • => will fail!
  • Why? SSH, default, is looking for a file called id_rsa to match with, we named our keys github.
  • To make this work, run the command:
ssh -i 'path_to_private_key' -T git@github.com

ssh -i 'github' -T git@github.com
  • You will need to run this line everytime you push and pull code, again for authenticating yourself.
  • To avoid this, you can specify in a config file a shorter way:
  • In the .ssh folder, create a file called config: In this file, specify the following:
    Host github.com
        IdentityFile ~/.ssh/github
  • Host: name of the domain you are authenticating with
  • IdentifyFile: private key, which will be matched to the public key already known by github from when it was uploaded.
  • You can always add more hosts and identity files for easier authentication.
  • The config file in the .ssh folder is different than the config file for git!
  • This config file is used to easily provide the private key for authenticating with a domain.
  • To edit configurations for git use the command:
git config --global --list