DEV Community

Cover image for Adding SSH key to GitHub
Bruno Drugowick
Bruno Drugowick

Posted on • Updated on

Adding SSH key to GitHub

It's fairly easy to follow GitHub's official documentation on how to add your SSH key to your account. This version is quickier and you can find all necessary commands below. Follow this if you use a Linux distribution.

You can follow this procedure with a few modifications for GitLab and Bitbucket.

Generating a SSH key

Check the existence of a key:

ls -al ~/.ssh

The filenames of the public keys are one of the following:

  • <-- that's mine

Generate a new SSH key if necessary

ssh-keygen -t rsa -b 4096 -C ""

You'll see this:

> Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]

Just [press enter] as instructed to use the default location or type one of your preference.

Then you'll be prompt to define a passphrase. Be creative.

Adding an SSH key to GitHub

To get your ssh public key you can run ls -al ~/ssh, identify you public key and then cat its content to the console. For example:

cat ~/.ssh/


Now all operations to/from GitHub (clone, pull, push and others) can be performed safely without typing user and password every time.

Imagem de mikex7 por Pixabay

Discussion (0)