Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 1.71 KB

SSHSetup.md

File metadata and controls

68 lines (47 loc) · 1.71 KB

Setting up an SSH key for Github

Github changed their policies to require token-based authentication.

Generate the token

First, if you do not have a ~/.ssh directory, do

$ mkdir .ssh
$ chmod 600

Then run ssh-keygen.

$ cd .ssh
$ ssh-keygen -t ed25519 -C "[email protected]"

Specify a name for your key and (optionally) a password. This will produce a private key and a public key (ends in .pub).

On your Github account, under Settings/SSH and GPG keys, create a new SSH key and copy and paste the contents of the public key.

NOTES:

  • Make sure that your keys are in the ~/.ssh directory
  • Make sure the ~/.ssh directory has permissions drwx--x--x. If not run chmod 755 .ssh
  • Make sure the private key has permissions -rw-------. If not run chmod 600 <private_key>

Clone the respository

Make sure that you clone the repository using the SSH url.

Local account setup

You may need to also set up the ssh-agent for you keys to work. Add the following lines to ~/.bashrc

# .bashrc
eval `ssh-agent -s`
ssh-add ~/.ssh/<private_keyname>

To test that your .bashrc works, run

$ source .bashrc

Check the hidden files in your home directory using ls -a. If you do not have a .bash_profile, add one with the following contents

# .bash_profile

# If .bash_profile exists, bash doesn't read .profile
if [[ -f ~/.profile ]]; then
  . ~/.profile
fi

# If the shell is interactive and .bashrc exists, get the aliases and functions
if [[ $- == *i* && -f ~/.bashrc ]]; then
    . ~/.bashrc
fi

References: