connection refused error for ssh while HTTP urls are working without an issue
Created by: rockneverdies55
Hi all --
I cannot clone/push/pull/fetch using ssh urls but interestingly http urls are working normally.
I'm getting the following output when I run /home/git/gitlab-shell/bin/check in the server:
Check GitLab API access: /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /usr/local/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /usr/local/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /usr/local/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /usr/local/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:29:in `check'
from ./gitlab-shell/bin/check:11:in `<main>'
Also if I try to connect to server from a local client with ssh -T git@<server_ip> -p <port>
then the output is:
Enter passphrase for key '/home/<user_name>/.ssh/id_rsa':
/usr/local/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /usr/local/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /usr/local/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /usr/local/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /usr/local/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:24:in `discover'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:77:in `user'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:82:in `username'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:37:in `exec'
from /home/git/gitlab-shell/bin/gitlab-shell:16:in `<main>'
Based on the first output, I opened up /usr/local/lib/ruby/2.0.0/net/http.rb
in my editor. Found the line 878:
puts "opening connection to #{conn_address}:#{conn_port}..."
So I've added the following line before the line in question:
puts "Conection Adress: #{conn_address} - Connection Port: #{conn_port}!..."
The output had the correct IP and correct port. This quick check reminded me that Comcast Business Modem strangely doesn't allow accessing to the network with external IP... So I have changed gitlab_url to local ip of the server in gitlab-shell config.yml file. After that /gitlab-shell/bin/check
script stopped giving the error. But unfortunately I was still not able to clone via ssh url's from server to my local machine.
Here is the new output in the local machine:
Cloning into 'the_project'...
Enter passphrase for key '/home/<user_name>/.ssh/id_rsa':
/home/git/gitlab-shell/lib/gitlab_shell.rb:94:in `escape_path': Wrong repository path /<user_name>/the_project.git (RuntimeError)
from /home/git/gitlab-shell/lib/gitlab_shell.rb:46:in `parse_cmd'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:19:in `exec'
from /home/git/gitlab-shell/bin/gitlab-shell:16:in `<main>'
fatal: The remote end hung up unexpectedly
So I opened up /home/git/gitlab-shell/lib/gitlab_shell.rb
file and found the line 96, which checks if the absolute url is matching with joint path, but for some reason this check fails and falls onto the else statement which returns an error instead.
When I copied whatever is in if block onto else block in escape_path function, I was able to clone/push via ssh urls...
But then cannot create a new user, the error message tells me username can only contain letters and etc even though I only have letters in the username I'm trying to create.
Any idea what is going on here? Thanks.