HomeContact
Git
How to setup SSH key for git service (Github, Gitlab, etc ...)
March 23, 2020
1 min

SSH key exists not to make our life harder but so much simpler. Yes yes, you will see !

If you end up here it’s probably because you encountered a problem like : Permission denied (publickey) fatal : Could not read from remote repository.

Let’s see how to solve that ! First, a quick recap on SSH key. SSH key are key generated by your computer that you enter in a remote service so that it knows that it’s yours and attribute the right permission to it. It’s like a computer ID for git.

To add SSH key to your favorite git manager follow the steps (before all of that you need to have git install on your computer) :

  • First you need to run a bash console with git in it (for Windows you can use git bash, and don’t forget to right-click and run as administrator)
  • Then type ssh-keygen, press enter
  • You should be then asked to choose a directory where to save your SSH key, don’t forget it ! (default is root)
  • You`ll then be asked a password to protect to file, it’s not mandatory to put one
  • The key is now generated ! Go to your folder, then in the folder .ssh (it’s a hidden folder), open the file id_rsa.pub. If you have VSCode and working command you can just type : code {chosenDirectory}/.ssh/id_rsa.pub
  • Copy all the text
  • Go to Gitlab keys section or Github one
  • Define a suitable name to remember and copy all text in Key section.
  • Validate

That’s it ! You successfully added a SSH key to your Git provider ! You will now be able to pull and push without errors !


Related Posts

How to remove or change remote origin from a Git repository
September 19, 2023
1 min
© 2023, All Rights Reserved.

Quick Links

Contact Us

Social Media