Thursday, July 27, 2017

SSH github setup

Simple instructions for setting up your github passwordless login

NOTE: After the ssh key is setup then you should clone using the github ssh link and not the http link

Generate a new key

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

Add the _rsa.pub key contenthere

https://github.com/settings/keys

# turn on ssh-agent
eval "$(ssh-agent -s)"

# add keys to ssh-agent
ssh-add ~/.ssh/*rsa

# check that that keys have been added to ssh-agent
ssh-add -l

# verify that you can log into github with the ssh key
ssh -vT git@github.com
...
Hi nnnnnnn! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3736, received 2060 bytes, in 0.3 seconds
Bytes per second: sent 14760.2, received 8138.7
debug1: Exit status 1

# setup the ssh key to be read by the agent at startup
https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-password-prompt

ssh-key with passphrase, with ssh-agent
Adding the following to ~/.bash_profile will automatically start ssh-agent and load the ssh-key(s) on login:
if [ -z "$SSH_AUTH_SOCK" ] ; then
  eval `ssh-agent -s`
  ssh-add
fi
Now the passphrase must be entered upon every login. While slightly better from a usability perspective, this has the drawback that ssh-agent prompts for the passphrase regrdless of if the key is to be used or not during the login session. Each new login also spawns a distinct ssh-agentinstance which remains running with the added keys in memory even after logout, unless explicitly killed.
To kill ssh_agent on logout, add the following to ~/.bash_logout
if [ -n "$SSH_AUTH_SOCK" ] ; then
  eval `/usr/bin/ssh-agent -k`
fi
or the following to ~/.bash_profile
trap 'test -n "$SSH_AUTH_SOCK" && eval `/usr/bin/ssh-agent -k`' 0
# verify that you can log into github with the ssh key
ssh -vT git@github.com
...
Hi nnnnnnn! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3736, received 2060 bytes, in 0.3 seconds
Bytes per second: sent 14760.2, received 8138.7
debug1: Exit status 1

# setup the ssh key to be read by the agent at startup

Github SSH key setup help

Trouble shooting



No comments:

Post a Comment