9

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 git@git.com 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/

Makogan
  • 8,208
  • 7
  • 44
  • 112
Jānis Blaus
  • 163
  • 1
  • 2
  • 7
  • SSH key has passphrase, may it asks for passphrase ? – midan888 Mar 15 '15 at 13:21
  • I suppose `git.com` is a fake name for your GitLab server? What OS are you using as a client accessing to your GitLab server? What version og Git are you using? Are the permssion ok (as in http://stackoverflow.com/a/26967270/6309, I mentioned in http://stackoverflow.com/a/28793643/6309). – VonC Mar 15 '15 at 13:21
  • 1
    Wait, are you using github or gitlab? They're completely different, unrelated (though visually and functionally similar) things. – liamness Mar 15 '15 at 13:23
  • I`m using my domain name instead of git.com I`m using linux(can`t specify OS because of my companies politics) on my server. And as client - it`s Ubuntu 14.04. Git version is 1.9.1. Yes, permissions are okay. And I`m using gitlab!! – Jānis Blaus Mar 15 '15 at 16:05
  • Then try the debug options I propose in http://stackoverflow.com/a/26967270/6309: `ssh -Tvvv git@git.com` and `/usr/sbin/sshd -d` on the server. – VonC Mar 15 '15 at 16:49

4 Answers4

4

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)

emonik
  • 1,540
  • 1
  • 17
  • 24
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

Jérémie Bertrand
  • 3,025
  • 3
  • 44
  • 53
serdroid
  • 166
  • 2
  • 7
2

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/.

1

Try using git@gitlab.com:.... instead of https://gitlab.com/... protocol.

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

Md Arif Islam
  • 57
  • 2
  • 6
  • 1
    For anyone reading this who doesn't know how to change the protocol for their repo, the command to use is `git remote set-url`. (Blatant self-promotion) I wrote an answer about it for a similar question here: https://stackoverflow.com/a/67527810/10634604 – hasManyStupidQuestions May 14 '21 at 00:51