Added SSH key to Gitlab but it still asks for my credentials

15,601

Solution 1

I had the same issue, after checking

/var/log/auth.log

I got :

*User git not allowed because account is locked
*input_userauth_request: invalid user git [preauth]
*Connection closed by IP.IP.IP.IP [preauth]

So the fix was

sudo passwd -d git

Thanks to Noah (source)

Solution 2

I had similiar problem with new installation of gitlab. After some investigation I've seen below message shown in systemctl status sshd:

Accepted publickey for git from 10.x.x.x port 50858 ssh2: RSA 67:01:..

User git from 10.x.x.x not allowed because none of user's groups are listed in AllowGroups

Adding git user into sshusers group solve my problem.
Hope this helps

Solution 3

I realize this is a superold question, but I will post this regardless.

In my case it was an SELinux issue. Either disable it or ensure that authorized_keys has the SELinux type of ssh_home_t with

semanage fcontext -a -t ssh_home_t "/home/git/.ssh/authorized_keys"

Where /home/git is the path the git user's home directory. Mine was /var/opt/gitlab/.

Solution 4

Try using [email protected]:.... instead of https://gitlab.com/... protocol.

I think this is the reason your key is not being used for authentication.

Share:
15,601
Jānis Blaus
Author by

Jānis Blaus

Updated on July 26, 2022

Comments

  • Jānis Blaus
    Jānis Blaus almost 2 years

    GitLab's HTTP pull & push are working when I enter my credentials.

    But when using an added SSH key, it is always is asking for my password, which I don't know. Why is GitLab doing this? Is it a server fault?

    And when calling ssh -vT [email protected] there is an error:

    Permission denied (publickey)

    I've tried everything, even re-installing Git, but nothing works. Even their own solution is not working, as described here: https://help.github.com/articles/error-permission-denied-publickey/