git GitLab 和 SSH/HTTP 连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19605691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GitLab and SSH/HTTP connection
提问by Fez Vrasta
I've just set up an Ubuntu 64bit server dedicated to GitLab.
我刚刚设置了一个专用于 GitLab 的 Ubuntu 64 位服务器。
I have successfully installed GitLab and everything seems to work except for the SSH connection using a Git client ( SmartGit ).
我已经成功安装了 GitLab,除了使用 Git 客户端 (SmartGit) 的 SSH 连接外,一切似乎都正常工作。
I click on "Clone", then I insert the ssh git URL:
我单击“克隆”,然后插入 ssh git URL:
[email protected]:root/firstproject.git
When I click on "Next" it gives me this error:
当我点击“下一步”时,它给了我这个错误:
Please check the repository URL.
Could not read from remote repository.: /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'initialize': getaddrinfo: Name of service not know (SocketError)
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'open'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'block in connect'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'timeout'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'connect'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'do_start'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'start'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'get'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'allowed?'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'validate_access'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in 'exec'
from /user/local/lib/ruby/2.0.0/net/http.rb:878:in '<main>'
Please make sure you have the correct access rights and the repository exists.
I have tried to generate an SSH key and put it in /home/git/.ssh/config
but the problem remains the same.
I've even added it as "key" using the Gitlab control panel from web browser.
我试图生成一个 SSH 密钥并将其放入,/home/git/.ssh/config
但问题仍然存在。
我什至使用 Web 浏览器的 Gitlab 控制面板将其添加为“密钥”。
I have tried to restart GitLab and SSH but it didn't help. The HTTP method works, but gives me an error if I commint&push lot of files at the same time:
我曾尝试重新启动 GitLab 和 SSH,但没有帮助。HTTP 方法有效,但如果我同时提交和推送大量文件,则会出现错误:
The remote end hung up unexpectedly
The remote end hun up unexpectedly
RPC failed; result=22, HTTP code = 411
Counting objects: 89, done
Delta compression using up to 8 threads.
Total 88 (delta 12), reused 0 (delta 0)
I don't need to fix both problems, I just need to have one of them fully working.
我不需要解决这两个问题,我只需要让其中一个完全正常工作。
回答by Ash Wilson
From the stack trace, it looks like gitlab-shell
can't resolve the server's own hostname in DNS to verify repository permissions with GitLab's web API. Try logging into the server and running:
从堆栈跟踪来看,似乎gitlab-shell
无法在 DNS 中解析服务器自己的主机名,以使用 GitLab 的 Web API 验证存储库权限。尝试登录服务器并运行:
nslookup mydomain.test
nslookup mydomain.test
Where "mydomain.test" is the hostname you're using in the gitlab_url:
setting in gitlab.yml
. If you see an error like ** server can't find mydomain.test
in the output, this is your problem.
其中“mydomain.test”是您gitlab_url:
在gitlab.yml
. 如果您** server can't find mydomain.test
在输出中看到类似错误,这就是您的问题。
If so, you can fix this by either:
如果是这样,您可以通过以下任一方式解决此问题:
- Correcting the DNS configuration of your server by editing /etc/resolv.confso that it can resolve your hostname properly. The DNS servers you need to add depend on your hosting environment; you'll have to talk to someone who administers your network to find the proper values.
- Changing
gitlab_url
to usehttp://localhost/
instead of the externally-routable domain name. - Adding an entry to /etc/hostson your server for
mydomain.test
that points to 127.0.0.1.
- 通过编辑/etc/resolv.conf更正服务器的 DNS 配置,以便它可以正确解析您的主机名。您需要添加的 DNS 服务器取决于您的托管环境;您必须与管理您网络的人交谈才能找到正确的值。
- 更改
gitlab_url
为使用http://localhost/
而不是外部可路由的域名。 - 向服务器上的/etc/hosts添加一个条目
mydomain.test
,指向 127.0.0.1。
回答by VonC
Make sure this isn't a configuration issue, as reported in issue 3324:
确保这不是配置问题,如问题 3324 中所述:
sudo -u git -H vim /home/git/gitlab-shell/config.yml
and change:
gitlab_url: http://yourhost to gitlab_url: http://yourhost/
Slash at the end is important.
sudo -u git -H vim /home/git/gitlab-shell/config.yml
并改变:
gitlab_url: http://yourhost to gitlab_url: http://yourhost/
最后的斜线很重要。