为什么ssh连接到gitlab不起作用(http推送和克隆工作正常)?

时间:2013-07-18 14:26:52

标签: ubuntu ssh gitlab

我在旧电脑上运行x86 raring ringtail并安装了bitnami gitlab 5.3。

尝试在SSH模式下推送第一个主分支时,这是我的错误消息:

fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

(它在http协议中使用gitlab web仪表板凭据)

  1. 我已使用bitnami-installer.run用户启动root,因此我认为所有文件都在/opt而不是/home(这是一个很好的程序?)
  2. 我在安装GitLab之前没有git用户,因为我听说它可能会导致.ssh/authorized_keys文件和其他权限混淆。
  3. 当我运行ssh -T git@my-server.com时,它显示permission denied (public key),但客户端计算机上的pub键也位于.ssh/authorized_keys
  4. authorized_keys也有适当的内容,每行:

    command= "/opt/gitlab/apps/"
    
  5. 我还注意到我无法使用authorized_keys显示sudo -su git nano authorized_keys文件的内容,因为:

      

    用户不在sudoers文件中。

  6. 但是sudo /opt/gitlab/apps/gitlab/gitlab-shell/bin/check会为每次验证返回ok(gitlab api,acces,repo和/home/git/.ssh/authorized_keys文件(因为我在config.yml中设置了gitlab_url:{{ 3}}(本地服务器IP地址)而不是http://myserver.com/gitlab)。我注意到我有gitlab-shell目录的“两个版本”,一个在/opt,一个在/home而且我不知道它是否是适当的举止?

  7. 当我尝试ssh -Tv时,似乎ssh服务器甚至不接受我的密钥,无法进行身份验证并最终返回“权限被拒绝”。
  8. 除了/var/log/auth.log以外的shd[number] : connection closed by IP address个文件中没有什么特别的。
  9. authorized_keys文件路径设置为/etc/ssh/sshd_config文件中的正确绝对网址(/home/git/.ssh/authorized_keys)
  10. 最后我无法使用«bundle exec bin / rake»调试,因为我无法让我的ubuntu安装所有必需的pacakge来执行bundle。
  11. 我几乎可以肯定,在author_keys文件中调用command="/opt/...../gitlab-shell"时,这是一个简单的ssh配置错误或出错的地方

    PS:使用带有HTTP protocole的git对我的家庭服务器来说已经足够了,但是gitlab仪表板的兴趣在于通过填写Web表单中的ssh密钥并在

    之后使用ssh来轻松添加贡献者。

4 个答案:

答案 0 :(得分:5)

我尝试通过ssh从新安装的gitlab克隆repo时出现以下错误:

  

致命:无法从远程存储库中读取。

     

请确保您拥有正确的访问权限和存储库   存在。

https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#ssh

找到了解决方案

检查ssh log /var/log/auth.log,如果发现错误:

User git not allowed because account is locked

然后修改/etc/shadow并更改git:!: to git:*:

P.S。 在我的CentOS 6.5案例中,它是/ var / log / secure和git:!!:

答案 1 :(得分:1)

我有同样的错误。搜索并尝试了很多方式。它没用。 然后,我在此网站[http://georgik.sinusgear.com 1找到了答案。它对我有用。

我的gitlab版本是6.6.4。

执行以下操作:

  1. 找到端口独角兽运行:

      

    sudo emacs /home/git/gitlab/config/unicorn.rb

  2.      在Unix域套接字和TCP端口上滚动到#jack,发现:   听“127.0.0.1:port”,:tcp_nopush =>真

    1. 编辑config.yml

        

      sudo emacs /home/git/gitlab-shell/config.yml

    2.      更改   gitlab_url:“你的域名”

        

      gitlab_url:“127.0.0.1:[port]”

      重启gitlab

        

      sudo service gitlab stop

           

      sudo service gitlab start

答案 2 :(得分:0)

检查.ssh文件夹的权限。

以git用户身份登录并使用

进行设置
sudo su - git
chmod 700 ~/.ssh
chmod 600 ~/authorized_keys

如果仍有问题,请使用ssh的详细输出获取更多信息

ssh -v  ssh -T git@my-server.com

(如果启用并执行selinux,也可能是selinux上下文问题,请参阅this blog

答案 3 :(得分:0)

我需要将我的公钥添加到/home/git/repositories/.ssh/authorized_keys。似乎没有使用/home/git/.ssh中的authoried_keys。

  1. 将您的公钥添加到authorized_keys

    cat id_rsa.pub >> /home/git/repositories/.ssh/authorized_keys
    
  2. 确保git是文件的所有者

    chown git /home/git/repositories/.ssh/authorized_keys
    
  3. 确保群组是git

    chgrp git /home/git/repositories/.ssh/authorized_keys
    
  4. 设置文件模式位

    chmod 600 /home/git/repositories/.ssh/authorized_keys