Gitlab 6.2无法与authorized_keys同步

3

我在Gitlab界面上输入的密钥没有显示在authorized_keys文件中。因此,我无法通过ssh推送或拉取代码。每次尝试都要求我输入ssh密码 :-(

我使用的是Gitlab 6.2稳定版。以下是一些命令的输出:

git@CVIAL272675:~/gitlab$ bundle exec rake gitlab:shell:setup RAILS_ENV=production
This will rebuild an authorized_keys file.
You will lose any data stored in authorized_keys file.
Do you want to continue (yes/no)? yes

sh: 1: Syntax error: Unterminated quoted string
Fgit@CVIAL272675:~/gitlab$

并且。
git@CVIAL272675:~/gitlab$ bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...

Git configured for git user? ... yes
Has python2? ... yes
python2 is supported version? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version >= 1.7.1 ? ... OK (1.7.1)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
Snehadeep Sethia / CodeRush ... ok
Bharath Bhushan Lohray / PyPGPWord ... ok
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
        /home/git/repositories: OK
        /home/git/.ssh/authorized_keys: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
projects have namespace: ...
Snehadeep Sethia / CodeRush ... yes
Bharath Bhushan Lohray / PyPGPWord ... yes
Projects have satellites? ...
Snehadeep Sethia / CodeRush ... yes
Bharath Bhushan Lohray / PyPGPWord ... yes
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.8.3)

Checking GitLab ... Finished

git@CVIAL272675:~/gitlab$

sidekiq.log

2013-10-29T04:08:37Z 18931 TID-os8rme7b4 INFO: Booting Sidekiq 2.14.0 using redis://localhost:6379 with options {:namespace=>"resque:gitlab"}
2013-10-29T04:08:37Z 18931 TID-os8rme7b4 INFO: Running in ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
2013-10-29T04:08:37Z 18931 TID-os8rme7b4 INFO: See LICENSE and the LGPL-3.0 for licensing details.
2013-10-29T04:10:55Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-10b66a2f8897dd56487c57cd INFO: start
2013-10-29T04:10:56Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-10b66a2f8897dd56487c57cd INFO: done: 0.472 sec
2013-10-29T04:11:55Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-a63f9cad0c98b605c76e0613 INFO: start
2013-10-29T04:11:55Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-a63f9cad0c98b605c76e0613 INFO: done: 0.263 sec
2013-10-29T04:14:36Z 18931 TID-os8s00k6g GitlabShellWorker JID-af69358238a2b2cc4c5884c2 INFO: start
sh: 1: Syntax error: Unterminated quoted string
2013-10-29T04:14:37Z 18931 TID-os8s00k6g GitlabShellWorker JID-af69358238a2b2cc4c5884c2 INFO: done: 0.757 sec
2013-10-29T04:14:40Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-4020b22e54a09bc63401f08b INFO: start
2013-10-29T04:14:41Z 18931 TID-os8s00k6g Sidekiq::Extensions::DelayedMailer JID-4020b22e54a09bc63401f08b INFO: done: 0.29 sec

还有什么其他办法吗?我该如何解决这个问题?我在stackoverflow和其他地方看到了类似的帖子,但没有一个适用于我。


看看这里的答案是否有所帮助:https://dev59.com/r2Ik5IYBdhLWcg3wDaQW#19637026 - Ash Wilson
看过了,不起作用。那是针对4.1的,我正在使用6.2。 - Lord Loh.
嗯,好的。(实际上我误写成了6.2,尽管问题是针对4.1的。但如果它对你不起作用,那就无法解决。)所以在任何日志中都没有失败消息...?gitlab-shell执行的stdout和stderr应该显示在sidekiq的日志中... - Ash Wilson
既然你提到了,确实有这个问题。我已经更新了我的问题,加上了 Sidekiq 的错误日志。 sh:1:语法错误:未终止引用字符串 当我尝试运行 bundle exec rake gitlab:shell:setup RAILS_ENV=production 时出现了相同的错误。 - Lord Loh.
1个回答

5
问题出现在GitLab调用外部程序以执行gitlab-shell添加密钥时;看起来引号字符不知怎么悄悄地混入了对#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys的调用中。因为key.shell_id不能包含引号,它是生成为“key-#{id}”的,而key.key验证为可识别的ssh-rsa密钥,所以我认为最有可能的是#{gitlab_shell_user_home}多了一个无关字符。

如果有可能的话,你可以在系统调用之前添加 puts "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} #{key_content}(并重新启动 sidekiq)来验证。这样就可以看到 GitLab 即将尝试的实际 shell 命令。这应该可以帮助你找出额外引号的来源。

如果 gitlab_shell_user_home 是问题所在,那么该值是从 gitlab.yml 中的 gitlab-shell: ssh_user: 设置中派生出来的,如果没有设置,则默认为 gitlab:user。如果你已经设置了其中之一,请仔细检查你的 YAML 语法!


非常感谢!我在这上面浪费了一整天!我的密钥里有一个引号 - ssh-rsa AAAA...ibeQ== Bharath's Key - L2 我把注释中的 's 去掉了,然后它就可以工作了! - Lord Loh.
只需从gitlab.yml中取消注释"user: git",以确保没有奇怪的引号,就可以正常工作了! - Dj Mamana

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接