Getting permission denied (public key) on gitlab

前端 未结 30 2266
太阳男子
太阳男子 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:50

    The problem for me was, that I switched UsePAM from yes to no in the SSH configuration file under /etc/ssh/sshd_config. With UsePAM yes everything works perfectly.

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

    I added my ~/.ssh/id_rsa.pub to the list of known SSH Keys in my GitLab settings https://gitlab.com/profile/keys. That solved the problem for me. :-)

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

    Step 1: Added a config file in ~/.ssh/config file which looks like

       User git
       Hostname gitlab.com
       IdentityFile ~/.ssh/id_rsa_gitlab
       TCPKeepAlive yes
       IdentitiesOnly yes
    

    Step 2: Just clone the git repo WITHOUT sudo.
    Documentation: https://gitlab.com/help/ssh/README#working-with-non-default-ssh-key-pair-paths

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

    In my case, it wasn't a gitlab problem, but a sshd configuration one. The ssh server didn't allow connection except for a list of users. The user git, the one connecting remotely to gitlab, wasn't in that list. So, check this before anything else.

    You can check your ssh server configuration in /etc/ssh/sshd_config. If you have a line with the option AllowUsers, add git to it:

    AllowUsers user1 user2 user3 git
    
    0 讨论(0)
  • 2020-12-02 04:55

    I have gitlab running with docker, this is what I did to fix my problem.

    Found that inside docker /var/log/gitlab/sshd/current there were multiple occurences of a message:

    Authentication refused: bad ownership or modes for file /var/opt/gitlab/.ssh/authorized_keys

    After which I changed ownership of that file from 99:users to git:users with:

    chown git:users authorized_keys

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

    Go to the terminal and regenerate the ssh key again. Type ssh-keygen. It will ask you where you want to save it, type the path.

    Then copy the public key to gitlabs platform. It usually starts with ssh-rsa.

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