Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #5612

Closed
Open
Created 11 years ago by Administrator@rootOwner
  • New issue

  • Report abuse

  • New issue

  • Report abuse

connection refused error for ssh while HTTP urls are working without an issue

Closed

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.

Linked issues
...

    Related merge requests

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: hupili

      I had a similar issue with 6-2-stable.

      When I execute bundle exec rake gitlab:check RAILS_ENV=production, everything is reported OK. I can also access Git repo using http URL. When I access with SSH URL, the following error arises:

      git@gitlab:~/test$ git clone ssh://git@localhost:2222/root/test.git
      Cloning into 'test'...
      /home/git/gitlab-shell/lib/gitlab_shell.rb:94:in `escape_path': Wrong repository path (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: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.

      By Administrator on 2013-11-20T11:14:43 (imported from GitLab project)

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: hupili

      I think it is the problem of the leading / in path variable. Following is my quick test and modification.

      print out the paths involved:

      abs_path = File.absolute_path(path, repos_path)
      join_path = File.join(repos_path, path)
      raise "Wrong repository path #{path}, #{repos_path}, #{abs_path}, #{join_path}"
      ...
      /home/git/gitlab-shell/lib/gitlab_shell.rb:99:in `escape_path': Wrong repository path /root/test.git, /home/git/repositories, /root/test.git, /home/git/repositories/root/test.git (RuntimeError)

      A leading / is preventing File.absolute_path to give the expected result. Following is what I do...

          if path[0] == '/'
            path = path[1..-1]
          end

      By Administrator on 2013-11-20T11:33:59 (imported from GitLab project)

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: rockneverdies55

      @hupili , for your reference, there was a similar discussion here

      By Administrator on 2013-11-20T16:19:59 (imported from GitLab project)

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: jvanbaarsen

      @Razer6 What core member can take a look?

      By Administrator on 2014-01-10T23:17:32 (imported from GitLab project)

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: Razer6

      @jacobvosmaer Could you take a look?

      By Administrator on 2014-03-22T23:15:12 (imported from GitLab project)

    • Administrator
      Administrator @root · 11 years ago
      Owner

      Created by: jacobvosmaer

      Looks like a number of different issues.

      • Check GitLab API access: /usr/local/lib/ruby/2.0.0/net/http.rb:878:ininitialize': Connection refused` routing problem from gitlab-shell to gitlabhq
      • /home/git/gitlab-shell/lib/gitlab_shell.rb:94:inescape_path': Wrong repository path` bug introduced by a security check in gitlab-shell, resolved in gitlab-shell 1.7.9

      By Administrator on 2014-03-24T12:08:58 (imported from GitLab project)

    • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
    Please register or sign in to reply
    0 Assignees
    Assign to
    Milestone
    No milestone
    None
    None
    Time tracking
    Due date
    None
    None
    0
    Labels
    None
    Assign labels
    • No matching results
    • Manage project labels
    Confidentiality
    Not confidential

    You are going to turn on confidentiality. Only team members with at least Reporter access will be able to see and leave comments on the issue.

    Lock issue
    Unlocked
    participants
    Reference:

    Menu

    Projects Groups Snippets
    Help