【问题标题】:Can't clone gitlab's repo via ssh, via http - OK无法通过 ssh、http 克隆 gitlab 的 repo - 好的
【发布时间】:2013-07-18 09:04:56
【问题描述】:

我是 gitlab 和 CI 的新手,所以我有很多问题,但其中一些是通过 google、SO、git mans 解决的,但不是最后一个......

我无法通过 ssh 克隆 repo =(

如果我尝试通过 http 克隆 repo:

lesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
Username for 'http://gitlab.vbox': root
Password for 'http://root@gitlab.vbox':
warning: You appear to have cloned an empty repository.

没关系!

但是通过 ssh ...

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into virtualbox 'gitlab'
git@gitlab.vbox's password:<br />   

它提示我安装时没有创建的 git 密码(就像我在 man 中一样)

rsa keys

我通过 gitlab 的网络添加了我的密钥(到帐户 root,实际上我没有创建任何其他帐户)

我还通过“cat my_rsa.pub >> authorized_keys”添加了密钥

我在这里读过一些关于 ssh 问题的帖子,但大多数都安装了 gitolite

我在没有 gitolite 的情况下安装了 gitlab 5.3(如手册中所述),我应该这样做吗?

我也试过ssh -vT git@gitlab.vbox,它输出:

....
debug1: Server host key: ECDSA 48:83:ba:b3:37:72:a0:dc:ca:2c:a3:b8:78:a1:c4:ad
debug1: Host 'gitlab.vbox' is known and matches the ECDSA host key.
debug1: Found key in /home/lesha/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/lesha/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/lesha/.ssh/id_dsa
debug1: Trying private key: /home/lesha/.ssh/id_ecdsa
debug1: Next authentication method: password
git@gitlab.vbox's password:


root@seotm-server:/home/git/.ssh# ls -l
итого 4
-rw------- 1 git git 922 Июл 18 21:05 authorized_keys

环境: debian 7,nginx + 乘客,gitlab 5.3,ruby 2.0.0p247,没有 gitolite,puma 对抗独角兽

请帮忙!=) 我卡住了...


一些补充(20.07.2013):

我在手动安装中创建了用户 git

sudo adduser --disabled-login --gecos 'GitLab' git

第二天,我试图杀死 git 并简单地通过 useradd 命令重新添加,之后我的密钥正在工作,但我仍然不开心,因为:

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
fatal: 'root/virtualboxgitlab.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

http 和以前一样工作:

lesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
Username for 'http://gitlab.vbox': root
Password for 'http://root@gitlab.vbox': 
warning: You appear to have cloned an empty repository.

所以,现在我没有身份验证问题,但有另一个问题。

您将如何从那里解决此问题?

【问题讨论】:

  • 我已经编辑了我的答案以回应您对问题的编辑:)

标签: gitlab


【解决方案1】:

GitLab 5.x doesn't use gitolite anymore,但gitlab-shell

我建议按照installation process 中的建议创建一个专用帐户。

ssh git@gitlab.vbox

该 ssh 命令意味着您以用户“git”的身份在“gitlab.vbox”上请求安全 shell。如果该用户不存在......它将无法工作。

如果测试运行不正常,则无需尝试克隆 repo:

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

OP 报告 ssh 在创建 git 用户并添加密钥后效果更好,但是:

  • 首先确保您在“客户”帐户而不是~git/.ssh/id_rsa 中创建密钥:您正试图从客户帐户以git 的身份打开会话。 git是安装gitlab的账号。
  • 然后您应该在您通过 gitlab gui 声明的用户帐户的 ssh 页面中注册您的公钥。您应该useradd”一个 ssh 到 root。

如果你看到这个:

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
fatal: 'root/virtualboxgitlab.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

这也意味着你不应该指定 repo 的路径 (root/):

 git clone git@gitlab.vbox:virtualboxgitlab.git

知道 virtualboxgitlab.git 的存储位置是 gitlab 的工作(在其 gitlab.yml 配置文件中指定)

基本上,忘记 root,并按照预期完成 gitlab 的完整安装:在“git”帐户中。

OP 让它发挥作用,并评论说:

"root" 是管理员命名空间,gitlab 自动创建这个 url,没有它克隆不起作用,现在一切都克隆了,我开始安装 gitlab CI,

OP 必须:

将我的用户添加到 sudo 组,进行全新安装,收到错误

/usr/local/lib/ruby/2.0.0/net/http.rb:878:in initialize': getaddrinfo: 
  Name or service not known (SocketError)

无法解析主机名,将gitlab.vbox添加到/etc/hosts

【讨论】:

  • 我按照安装指南一步一步地安装,没有错误,只有:Git configured for git user? ... no,我的 git 用户存在,git:x:1001:1001:GitLab,,,:/home/git:/bin/bash
  • 将我的用户添加到 sudo 组,进行全新安装,收到错误 /usr/local/lib/ruby/2.0.0/net/http.rb:878:in initialize': getaddrinfo: Name or service not known (SocketError)` which can't resolve hostname, added gitlab.vbox to @ 987654346@ adn 现在我几乎很高兴!=)关于回购路径的一句话,你告诉我不应该在路径中指定 root/,我应该这样做,“root”是管理员命名空间,gitlab 创建这个 url自动和没有它克隆不起作用,现在一切都克隆了,我开始安装 gitlab CI,非常感谢
猜你喜欢
  • 2019-01-25
  • 2018-08-24
  • 2021-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
相关资源
最近更新 更多