[github, ssh]

You'll have a better experience reading in DEV

Click here to continue reading this post there >>

However, if you want to know more about the project to mirror my posts from DEV here (and why), go ahead and read more.

You can continue to read here too, it's up to you... =]

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
Enter fullscreen mode Exit fullscreen mode

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

  • id_dsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub
  • id_rsa.pub <-- that's mine

Generate a new SSH key if necessary

ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter fullscreen mode Exit fullscreen mode

You'll see this:

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

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/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode


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