How to fix ” Permission denied (publickey) ” issue in Gitlab

When you try to clone private repositories for the first time from an account, you may get following error.

Permission denied (publickey).
Permission denied (publickey) fatal : Could not read from remote repository

Please make sure you have the correct access rights
and the repository exists.

This article helps you on fixing this issue. The root cause here is that the remote repository don’t trust you. In order to gain access to the repo, you have to create an SSH key and register that key in your git repository.

Steps to add SSH key in Gitlab

    1. Run CMD/Powershell/Terminal with administrative (sudo) privilege. (In windows run cmd as administrator. In linux execute ‘sudo su’ to get root privilege).
    2. Type ssh-keygen.
      You will see the following. Here you will be asked for the location where the SSH key will be saved. Press enter to accept default or enter your custom location.

      Generating public/private rsa key pair.     
      Enter file in which to save the key (C:\Users\yourUsername/.ssh/id_rsa):
    3. Git will ask you to save the key to the specific directory.You will be asked for a password. Make sure you remember it since it will be needed for cloning.
      Enter passphrase (empty for no passphrase):
    4. The public key will be created to the specific directory.
    5. Now go to the directory you have specified in Step 2 and open .ssh folder.
    6. You’ll see a file id_rsa.pub. Open it on notepad. Copy all text from it.
    7. Go to https://gitlab.com/profile/keys
      Here you can see all the SSH keys specified so far. Paste the copied key.
    8. Now click on the “Title” below. It will automatically get filled based on the value taken from the SHA Key.
    9. Then click “Add key” and that’s it. You have successfully configured SSH.
    10. Now try cloning again. Git will ask for a password. Give the password you have given in Step 2.

And that’s all. Now you will be able to access the repo without any issues.

Comments

52 responses to “How to fix ” Permission denied (publickey) ” issue in Gitlab”

  1. […] How to fix " Permission denied (publickey) " issue in Gitlab […]

  2. […] How to fix " Permission denied (publickey) " issue in Gitlab […]

  3. … [Trackback]

    […] Read More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  4. … [Trackback]

    […] Info to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  5. … [Trackback]

    […] There you will find 34749 additional Info to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  6. … [Trackback]

    […] Information on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  7. … [Trackback]

    […] There you can find 35303 more Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  8. … [Trackback]

    […] Read More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  9. … [Trackback]

    […] Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  10. … [Trackback]

    […] Read More Information here on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  11. … [Trackback]

    […] Find More here to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  12. … [Trackback]

    […] Read More on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  13. … [Trackback]

    […] Read More Information here on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  14. … [Trackback]

    […] Find More on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  15. … [Trackback]

    […] Read More Info here to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  16. … [Trackback]

    […] Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  17. … [Trackback]

    […] Read More on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  18. … [Trackback]

    […] Read More on to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  19. … [Trackback]

    […] Read More Information here to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  20. … [Trackback]

    […] Read More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  21. … [Trackback]

    […] Read More Info here on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  22. … [Trackback]

    […] Find More Info here on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  23. … [Trackback]

    […] There you will find 53837 more Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  24. … [Trackback]

    […] Find More on on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  25. … [Trackback]

    […] Information on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  26. … [Trackback]

    […] Info to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  27. … [Trackback]

    […] Information on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  28. … [Trackback]

    […] Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  29. … [Trackback]

    […] Here you can find 10109 additional Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  30. … [Trackback]

    […] Info on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  31. … [Trackback]

    […] Find More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  32. … [Trackback]

    […] Find More on on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  33. … [Trackback]

    […] Find More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  34. … [Trackback]

    […] Read More to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  35. … [Trackback]

    […] Read More Information here to that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  36. … [Trackback]

    […] There you can find 4490 additional Information on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  37. … [Trackback]

    […] Find More Information here on that Topic: genuinecoder.com/how-to-fix-permission-denied-publickey-issue-in-gitlab/ […]

  38. how to order androxal purchase no prescription

    buy cheap androxal generic online usa

  39. how to buy enclomiphene american express

    online order enclomiphene buy sydney

  40. order rifaximin price at walmart

    how to buy rifaximin canada online order

  41. how to buy xifaxan generic a canada

    buy cheap xifaxan without recipe

  42. online order staxyn cheap trusted

    how to order staxyn generic order

  43. discount avodart using mastercard

    generic avodart prices

  44. how to buy dutasteride cheap in canada

    discount dutasteride cost at walmart

  45. order flexeril cyclobenzaprine without rx online

    online order flexeril cyclobenzaprine generic sale

  46. how to order gabapentin canada suppliers

    cheapest buy gabapentin uk cheap purchase buy

  47. buying fildena canada with no prescription

    order fildena cheap with fast shipping

  48. discount itraconazole usa mastercard

    how to buy itraconazole generic name

  49. nejlevnト嬲ナ。テュ mテュsto na nテ。kup kamagra online

    kamagra xr online

  50. kamagra avec fedex de nuit

    acheter kamagra etats unis

Leave a Reply