Gitlab prompts for password while push for git user

≯℡__Kan透↙ 提交于 2019-11-29 23:40:00
Kgaut

I had the same problem but it was because my server only accept ssh login from users of "sshusers".

On /etc/ssh/sshd_config I had the following line :

AllowGroups sshusers

In order to fix this issue, I added git to sshusers group:

$ sudo adduser git sshusers 

And then it's working.

VonC

That should only mean that:

  • either the public ssh key was incorrectly registered in the user account

  • and/or the public/private ssh keys aren't accessible from the user account (~/.ssh incorrectly protected, incorrect names different from id_rsa, id_rsa.pub, incorrect ~/.ssh/config file).
    See more, for instance, at "Git SSH authentication".

The OP swaroopsm comments:

I solved the issue by re-installing gitlab on the server. Now all is fine.

Stanislav Bondar

In my case, I had to add the remote repository with ssh as

git remote add gitlab ssh://git@your.project:222/git/repo_name.git 

which made git not request me the password again. Note the use of ssh:// and port=222.

niccolox

I had a similar problem when I set the remote repository with the HTTP URL.

I changed it to use the SSH URL, and it worked fine:

git remote set-url gitlab git@gitlab.devekko.net:niccolox/cirm-website.git

On systems with SELinux enabled you should not disable SELinux as suggested in some answers.

To get along with the SELinux restrictions (iff they are the reason for the password prompt; check your /var/log/audit/audit.log ) change the security context for gitlab:

chcon -t user_home_dir_t /var/opt/gitlab/
chcon -t ssh_home_t /var/opt/gitlab/.ssh/
chcon -t ssh_home_t /var/opt/gitlab/.ssh/authorized_keys

(as suggested at the gitlab group)

To properly fix the selinux issues, use the following. Note that chcon is only temporary and will not survive a relabel or restorecon, so you should use semanage instead.

semanage fcontext -a -t user_home_dir_t "/var/opt/gitlab(/.*)?"
semanage fcontext -a -t ssh_home_t "/var/opt/gitlab/.ssh(/.*)?"
restorecon -rv /var/opt/gitlab

I tried many options but no success. The only that resolved for me was osxkeychain helper

See the tutorial here.

The tutorial is from github, but works great for gitlab too.

I had same issue. Mine was that SELinux was enabled. Please disabled SELinux here is the link http://www.how2centos.com/disable-selinux-centos-6/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!