Getting permission denied (public key) on gitlab

前端 未结 30 2267
太阳男子
太阳男子 2020-12-02 04:27

My problem is that I can\'t push or fetch from GitLab. However, I can clone (via HTTP or via SSH). I get this error when I try to push :

Permission de

相关标签:
30条回答
  • 2020-12-02 04:58

    Another issue that can cause this behaviour is when you have a setup with 2 possible %HOME%-locations.

    I'm using a PC where some of my documents are stored locally, and some of them are stored on a network drive. Some applications think C:\Users\<MyUserName>\ is my %home%, others think that U:\ is the home.

    Turns out ssh-keygen put my private key under C:\users\<MyUserName>\, and that ssh -T and ssh -v also look there.

    So everything seems to work fine, except that git clone, git push and others look for a key in U:\. Which fails, so I get the aforementioned error.

    It took me an hour to find out, but in the end the solution was simple: I copied everything from C:\Users\<MyUserName>\.ssh to U:\.ssh

    0 讨论(0)
  • 2020-12-02 04:58

    Change permission :: chmod 400 ~/.ssh/id_rsa It helped for me.

    0 讨论(0)
  • 2020-12-02 04:59

    For anyone using Windows 10 and nothing else working for him/her:

    In my case, I had to clone the repo with https instead of ssh and a window popped-up asking for my credentials. After that everything works fine.

    0 讨论(0)
  • 2020-12-02 04:59

    Two things mainly

    1. You must have id_rsa.pub and id_rsa (private) keys in your .ssh folder ( which should be in your home folder.Create it if it isn't there put your keys ). It wouldn't work If you have named your key files differently

    2. Change the permission of the id_rsa as chmod 400 ~/.ssh/id_rsa

    0 讨论(0)
  • 2020-12-02 05:00

    Well I had this same problem and after trying the answer @Khan proposed. However, I was only able to make it work by just changing the origin url in the .git/config file to the https address : https://gitlab.com/mygitlabusername/mygitproject.git

    Since access via ssh is denied, I figured out using https shouldn't be a problem. It will however ask for your username and password for each push to the at repository

    0 讨论(0)
  • 2020-12-02 05:00

    There seem to be differences between the two ways to access a git repository i.e. using either SSH or HTTPS. For me, I encountered the error because I was trying to push my local repository using SSH.

    The problem can simply be solved by clicking the clone button on the landing page of your project and the copying the HTTPS link and replacing it to the SSH link appearing with the format "git@gitlab...".

    0 讨论(0)
提交回复
热议问题