3

The keys I put in my Gitlab GUI are not showing up in the authorized_keys file. Hence I cannot push or pull over ssh. Any attempt asks me for an ssh password :-(

I am using gitlab 6.2 stable. Here are outputs to a few commands

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$

and

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

What else can I do? How do I fix this? I have seen similar threads on stackoverflow and elsewhere, none of them worked for me.

Lord Loh.
  • 2,437
  • 7
  • 39
  • 64
  • See if the answer here helps at all: http://stackoverflow.com/a/19637026/10556 – Ash Wilson Oct 29 '13 at 01:19
  • Seen it. Does not work. That is for 4.1 I am using 6.2 – Lord Loh. Oct 29 '13 at 02:11
  • Hmm, okay. (Actually I wrote it for 6.2 by mistake, even though the question was for 4.1. But if it doesn't work for you it doesn't work.) So there aren't any failure messages in any of the logs... ? stdout and stderr of the gitlab-shell execution should show up in sidekiq's log... – Ash Wilson Oct 29 '13 at 02:17
  • Now that you mentioned it, there is. I have updated my question with sidekiq error log. `sh: 1: Syntax error: Unterminated quoted string` This is the same error when I try to run - `bundle exec rake gitlab:shell:setup RAILS_ENV=production` – Lord Loh. Oct 29 '13 at 04:20

1 Answers1

5

The problem is happening when GitLab shells out to invoke gitlab-shell to add the key; it sounds like a quote character is sneaking into the call to #{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys somehow. key.shell_id can't have a quote in it, because it's generated as "key-#{id}", and key.key is validated as an recognizable ssh-rsa key, so it seems most likely to me that #{gitlab_shell_user_home} has an extraneous character.

To verify, if it's possible, you can add a puts "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} #{key_content} right before the system call (and restart sidekiq) to see the actual shell command that GitLab is about to attempt. That should let you track down where your extra quote is coming from.

If gitlab_shell_user_home, is the culprit, that value is derived from the gitlab-shell: ssh_user: setting in gitlab.yml, which defaults to gitlab: user if it's not present. Double check your YAML syntax if you've got either of those set!

Ash Wilson
  • 22,820
  • 3
  • 34
  • 45
  • Thanks a million! I wasted a day on this! My key had a quote in it - `ssh-rsa AAAA...ibeQ== Bharath's Key - L2` I removed the `'s` from the comments and it worked! – Lord Loh. Oct 29 '13 at 16:40
  • just uncommented the "user: git" from the gitlab.yml to make sure there are no strange quotes and worked! – Dj Mamana Nov 21 '13 at 18:21