我开始使用 gitlab:
rvmsudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
当我创建一个新项目时,我得到了远程 repo url:
git remote add origin ssh://git@gitlab.mydomain.com:12035/root/my_project.git
(so not the default 22 ssh port, but 12035)
因此,当我尝试将其推送到 gitlab 时:
git push --verbose -u origin master
然后我得到:
Pushing to ssh://git@gitlab.mydomain.com:12035/root/my_project.git
/home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /home/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in `start'
from /home/git/gitlab-shell/lib/gitlab_net.rb:62:in `get'
from /home/git/gitlab-shell/lib/gitlab_net.rb:17:in `allowed?'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:60:in `validate_access'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:23:in `exec'
from /home/git/gitlab-shell/bin/gitlab-shell:16:in `<main>'
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
所以我有两个用户:一个普通用户:kai
和git
gitlab 用户。但是gitlab
用户没有.ssh
目录。但是我已经从我试图推送到 gitlab 的远程机器上添加了 ssh-key。将密钥添加到~/.ssh/config
as:
Host gitlab.mydomain.com
User admin@local.host
# User Administrator
IdentityFile ~/.ssh/gitlab_rsa
附言
已经在此处查看了与该错误相关的所有类似问题。但要么没有得到答案,要么他们没有帮助
更新:
/var/log/auth.log
最后一次尝试中的行git push
:
Oct 13 06:53:04 80-69-77-159 sudo: kai : TTY=pts/2 ; PWD=/home/git/gitlab ; USER=root ; COMMAND=/usr/bin/less /var/log/auth.log
Oct 13 06:53:04 80-69-77-159 sudo: pam_unix(sudo:session): session opened for user root by kai(uid=0)
所以所有可能的用户都会出现在那里。这是什么意思?
更新 2:
我检查了 gitlab-shell:
sudo -u git -H /home/git/gitlab-shell/bin/check
并得到相同的结果:
http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
然后我将其更改gitlab_url
为https
in config.yml
:
sudo -u git -H nano /home/git/gitlab-shell/config.yml
gitlab_url: "http://gitlab.udesk.org/" -> gitlab_url: "https://gitlab.udesk.org/"
现在我从sudo -u git -H /home/git/gitlab-shell/bin/check
:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
现在可能是什么问题?
更新 3:
然后我将其更改self_signed_cert: false
为self_signed_cert: true
in /home/git/gitlab-shell/config.yml
。
现在我从sudo -u git -H /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
但仍然无法推送:
Pushing to ssh://git@gitlab.mydomain.com:12035/root/my_project.git
Access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
更新 4:
现在我注意到测试 ssh 行现在可以工作了:
> ssh -vT -p 12035 git@gitlab.mydomain.com
debug1: Authentication succeeded (publickey).
Authenticated to gitlab.mydomain.com ([x.x.x.x]:12035).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
Welcome to GitLab, Administrator!
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3264, received 3248 bytes, in 0.7 seconds
Bytes per second: sent 4782.6, received 4759.2
debug1: Exit status 0
更新 5:
在/home/git/gitlab-shell/gitlab-shell.log
对应的行中git push --verbose -u origin master
是:
W, [2013-10-13T15:18:05.276231 #24654] WARN -- : gitlab-shell: Access denied for git command <git-receive-pack '/root/myproject.git'> by user with key key-1.
还有什么问题?