2013-10-13 131 views
2

推到遠程服務器的git當我開始gitlab有:「拒絕連接 - 連接(2)(錯誤:: ECONNREFUSED)」從gitlab

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

當我創建一個新的項目,我得到遠程回購網址:

git remote add origin ssh://[email protected]:12035/root/my_project.git 

(so not the default 22 ssh port, but 12035) 

所以,當我嘗試將其推到gitlab:

git push --verbose -u origin master 

然後我得到:

Pushing to ssh://[email protected]: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. 

所以,我有兩個用戶:一個正常:kaigit的gitlab。但gitlab用戶沒有.ssh目錄。但是我已經從遠程機器添加了ssh-key,我嘗試將它推送到gitlab。鑰匙加入~/.ssh/config爲:

Host gitlab.mydomain.com 
     User [email protected] 
     # User Administrator 
     IdentityFile ~/.ssh/gitlab_rsa 

P.S.

已經研究了與錯誤有關的所有類似問題。但既沒有沒有得到答案,或者他們沒有幫助

更新:

/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殼有:

sudo -u git -H /home/git/gitlab-shell/bin/check 

,並得到了相同的:

http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED) 

config.yml再變gitlab_urlhttps

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: falseself_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://[email protected]: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 [email protected] 

debug1: Authentication succeeded (publickey). 
Authenticated to gitlab.mydomain.com ([x.x.x.x]:12035). 
debug1: channel 0: new [client-session] 
debug1: Requesting [email protected] 
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 [email protected] 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. 

可能是什麼仍是問題嗎?

+0

它是一個nginx配置問題,如在https://github.com/gitlabhq/gitlabhq/issues/3384#issuecomment-15457287(或https://github.com/gitlabhq/gitlab-shell/issues/20 #issuecomment-15333049)? – VonC

+0

我認爲不是。我現在沒有'Connection refused - connect(2)(Errno :: ECONNREFUSED)',但是'拒絕訪問.'。我不知道現在應該查看哪些日誌 – static

回答

1

後予執行(與gitlab在服務器上):

> pwd # just to get context 
    /home/git/gitlab 

> sudo -u git -H /home/git/gitlab-shell/bin/gitlab-keys clear 
> sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production 

然後除去GIT中遠程和背部再次加入它(與GIT回購本地服務器上推到gitlab):

> git remote remove origin 
> git remote add origin ssh://[email protected]:12035/root/myproject.git 

然後試圖推動:

> git push --verbose -u origin master 

Pushing to ssh://[email protected]:12035/root/myproject.git 
Counting objects: 401, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (289/289), done. 
Writing objects: 100% (401/401), 1.05 MiB | 98.00 KiB/s, done. 
Total 401 (delta 127), reused 0 (delta 0) 
To ssh://[email protected]:12035/root/myproject.git 
* [new branch]  master -> master 
Branch master set up to track remote branch master from origin. 
updating local tracking ref 'refs/remotes/origin/master' 

現在:

> cat /home/git/gitlab-shell/gitlab-shell.log 

I, [2013-10-13T15:38:49.332477 #24935] INFO -- : gitlab-shell: executing git command <git-receive-pack /home/git/repositories/'/root/myproject.git'> for user with key key-1. 
I, [2013-10-13T15:40:00.037092 #24958] INFO -- : Update head in project root/myproject.git to <master>. 

我不知道真正的問題在這裏,但試圖逐步調查它(首先修復gitlab_url問題,然後讓ssh使用回購協議,最後讓git工作正常)。我希望這些措施能夠幫助解決一些類似的問題(例如,在更新命名)

2

默認情況下,麒麟被配置爲監聽127.0.0.1:8080(/home/git/gitlab/config/unicorn.rb),所以gitlab_url需要將其設置爲http://yourURL:8080/

1

我意識到這是舊的文章,但爲一般的互聯網知識庫..在gitlab安裝的最新版本中得到這個錯誤,在apache2代理虛擬主機,但也適用於nginx。

好吧,得到了同樣的問題 - 這裏是我如何解決它;

在/home/git/gitlab/config/unicorn.rb

找到線

# listen on both a Unix domain socket and a TCP port, 
# we use a shorter backlog for quicker failover when busy 
listen "/home/git/gitlab/tmp/sockets/gitlab.socket", :backlog => 64 
listen "127.0.0.1:8080", :tcp_nopush => true 

更改最後一行

listen "0.0.0.0:8080", :tcp_nopush => true 

所以它接受不只是從連接本地機器。

1

再次,希望這可能對某人有用,某處;我有同樣的問題,並沒有建議的解決方案爲我工作。具體來說,我不關心HTTPS,我的GitLab沒有在Apache後面代理。

我的gitlab-shell的配置有gitlab_url: http://hostname:9999/。我的gitlab/config/unicorn.rb有listen "10.80.40.169:9999"。所以,我只是改變了gitlab_url以匹配unicorn.rb(gitlab_url: http://10.80.40.169:9999/),一切正常。

相關問題