Skip to content

Instantly share code, notes, and snippets.

@niyabits
Last active December 23, 2019 08:45
Show Gist options
  • Select an option

  • Save niyabits/364040c51aa57c3fad50f765eda4cee3 to your computer and use it in GitHub Desktop.

Select an option

Save niyabits/364040c51aa57c3fad50f765eda4cee3 to your computer and use it in GitHub Desktop.
Configure SSH for GitHub

Configure SSH on GitHub

All the commands at one go - (For lazy beings)

ssh-keygen -t rsa -b 4096 -C john@example.com # Generate SSH Key

ls -al ~/.ssh # Verify It

eval "$(ssh-agent -s)" # Max/Linux
ssh-agent -s # Windows

ssh-add ~/ .ssh/id_rsa 

pbcopy < ~/ .ssh/id_rsa.pub # Mac/Linux
clip < ~/ .ssh/id_rsa.pub # Windows
cat ~/.ssh/id_rsa.pub # If above don't work

ssh -T git@github.com # Verify

Use Git Bash if using Windows.

Verify SSH Key

ls -al ~/.ssh

If you already have an SSH key, please skip step 1.


1. Create ssh key

ssh-keygen -t rsa -b 4096 -C john@example.com 
  • You can use the default directory to store the key pair.
  • Optionally use a passphrase for an extra layer of security.

You can now verify this key using - ls -al ~/.ssh


2. Add ssh key to the ssh agent program

Mac/Linux:

eval "$(ssh-agent -s)"

Windows:

ssh-agent -s

3. Add rsa key to ssh

ssh-add ~/ .ssh/id_rsa 

4. Copy public pair of the ssh key

Mac/Linux:

pbcopy < ~/ .ssh/id_rsa.pub

Windows:

clip < ~/ .ssh/id_rsa.pub

5. Configure on GitHub

Go to settings > SSH keys > Add SSH key

  1. In Title enter the name of your computer
  2. In Key paste the key

6. Verify

ssh -T git@github.com

Enter Yes.

If you get Hi, then it is done


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment