gpt4 book ai didi

git - 从 gitlab 推送到远程 git 服务器时为 "Connection refused - connect(2) (Errno::ECONNREFUSED)"

转载 作者:太空狗 更新时间:2023-10-29 14:33:01 25 4
gpt4 key购买 nike

我开始使用 gitlab:

rvmsudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

当我创建一个新项目时,我得到了远程仓库 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 和用于 gitlab 的 git。但是gitlab用户没有.ssh目录。但是我已经从我试图推送到 gitlab 的远程机器添加了 ssh-key。 key 添加到 ~/.ssh/config 为:

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)

然后我在 config.yml 中将 gitlab_url 更改为 https:

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:

然后我在 /home/git/gitlab-shell/config.yml 中将 self_signed_cert: false 更改为 self_signed_cert: true

现在我从 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.

还有什么问题?

最佳答案

unicorn默认配置为监听127.0.0.1:8080(/home/git/gitlab/config/unicorn.rb),所以需要设置gitlab_urlhttp://yourURL:8080/

关于git - 从 gitlab 推送到远程 git 服务器时为 "Connection refused - connect(2) (Errno::ECONNREFUSED)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19341965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com