Gitlab CE Doesn't Add a Public Key to authorized_keys

我们两清 提交于 2020-05-14 09:00:26

问题


I just installed the newest Omnibus Gitlab in CentOS 7. I have added my public key to my account but gitlab keeps prompting me for a password every time I try to connect using ssh, like ssh git@mygitlab.com. The git home folder is /var/opt/gitlab.

Here are the various things that I've done:

  • I have checked that write to authorized_keys is checked in the admin area -> settings -> network

  • I have chmod the relevant folders and authorized_keys file. 0700 for home, 0711 for .ssh and 0600 for authorized_key file

  • I have deleted and re-created the authorized_keys file

  • I have checked various gitlab log files and nothing shows any clue

  • I have restarted and reconfigured using gitlab-ctl and restarted the computer


回答1:


You may want to configure Fast lookup of authorized SSH keys in the database.

This should solve the problem you're facing and it won't require manual rebuild of authorized_keys file whenever someone adds or removes SSH/deploy key in GitLab.

Edit: This bug was introduced with GitLab 12.9. It was confirmed and it should be resolved with 12.9.1 patch release, which is expected to be released soon.




回答2:


I have solved half of the problem although I don't know what the root cause was. I looked into this page docs.https://docs.gitlab.com/ee/administration/raketasks/maintenance.html#rebuild-authorized_keys-fileabout rebuilding authorized_keys using this command: sudo gitlab-rake gitlab:shell:setup, and gitlab rebuild the key and created authorized_keys.lock in the .ssh folder. Now, I can ssh -T git@mygitlab.com, although the user name was changed to Anonymous, now I'm facing another problem. When I try to clone or push, gitlab said the project can't be found. :( . I guess I'll have to look for it more.

EDIT: somehow by luck, I managed to solve this by creating a new user, added the ssh key for that user and run gitlab-rake gitlab:shell:setup again to make Gitlab added the public key to authorized_keys file.

What a mess in Gitlab and I see ton of issues regarding this authorized_keys and ssh from a long long time ago (5 - 6 years ago and still similar issue) and it still happens now.



来源:https://stackoverflow.com/questions/60844588/gitlab-ce-doesnt-add-a-public-key-to-authorized-keys

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