Using pubkey ssh authentication with GitHub


Home

by Linus Bohman cc by 2.0
  1. Generate a new public/private key pair
    ssh-keygen -f  $keyname
  2. Log into your GitHub account and go to Profile/Settings/SSH Keys
    Copy the contents of  $keyname.pub into the key field.
    Add the key by clicking on the Add Key button.
  3. Make sure you have ssh-agent running and add the key file to it by putting something like this in your .xinitrc or startup file
    eval `ssh-agent`
    ssh-add $key
    
  4. Go to the .git directory in your repo and change the url entry under [remote "origin"]
    url = git@github.com:$yourname/$yourrepo
  5. You can now push to to your repo without entering username or password.