GitLab SSH Port 22 Network is Unreachable

November 1, 2016 278 views
DigitalOcean Git Ubuntu 16.04

Hi,

I am getting the following message when trying to use git clone with ssh:

Cloning into '<ProjectName>'...
ssh: connect to host <url> port 22: Network is unreachable
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have the public key on my GitLab profile and the the private key in my C:/Users/<User>/.ssh folder on my local machine. I have tried the same key for cloning using SSH on GitHub and it works.

Any help on this issue would be greatly appreciated.

Thanks.

2 comments
  • Do you have a firewall?
    Have you tried to directly connect to gitlab via ssh so it can register it's fingerprint?

  • Yes, I have port 22, 80 and OpenSSH allowed.
    I have tried "ssh git.alexjamesbrown.me", it returns:

    ssh: connect to host git.alexjamesbrown.me port 22: Network is unreachable
    

    If this is what you mean, I'm new to this stuff.

1 Answer

There are a couple possible reasons for this:

1.) You are on a network which blocks traffic to port 22. Trying your connection from another network or device would be the best way to quickly test for this.

2.) The ssh service on your droplet is not running.

I would advise trying to access your droplet via the console in the control panel if you use password based authentication or have set a root password. This should allow you to check on and restart the ssh service if needed. If you do not have a root password I would recommend trying a reboot from the control panel to see if the ssh service comes back up. If it does not, open a ticket with our support team, they can boot your droplet to a recovery environment where you can investigate and resolve the issue.

  • It seems the issue is that port 22 is blocked by Virgin Media. Is there any way around this?

    • You can change the port that your ssh service listens on in the file /etc/ssh/sshd_conf

      In order to do this you would need to either access your droplet from the console if you have a password or reach out to support about the recovery environment if you do not. Make sure the port you choose is not blocked as well.

      • @TheHornyDonut I think in addition to that, change in GitLab config is required.

        You need to find config/gitlab.yaml and find port.
        This is how it looks in template. I'm not sure is this relevant but @ryanpq

      • I changed the port in /etc/ssh/sshd_config to 2222 then i uncommented and set gitlab_rails['gitlab_shell_ssh_port'] = 2222 in the /etc/gitlab/gitlab.rb file and reconfigured gitlab and restarted the ssh service, but it still seems to be using port 22:

        $ ssh git.alexjamesbrown.me
        ssh: connect to host git.alexjamesbrown.me port 22: Network is unreachable
        
        • You'll need to specify the non-standard port in your ssh command:

          ssh git.alexjamesbrown.me -p 2222
          
          • Got this back:

            $ ssh git.alexjamesbrown.me -p 2222
            ssh: connect to host git.alexjamesbrown.me port 2222: Network is unreachable
            

            I have just remembered I'm using bitvise ssh to connect to the droplet, which is using port 22, could that be causing the issue somehow?

          • The message shows that your ssh client is attempting to connect to port 2222. It is possible that your ISP is only allowing certain ports through. These are the ports most likely to be unblocked if you're not using them for other services (and the services that usually use them):

            80 - http
            443: https
            21: ftp
            53: dns
            8080: web proxy/etc

            I would recommend trying one of these in your ssh configuration to see if it makes a difference

          • @TheHornyDonut did you enabled that port in firewall? You said in above comment that you have firewall enabled:
            Yes, I have port 22, 80 and OpenSSH allowed.

            Make sure you allowed port 2222 in firewall.
            If you use ufw for firewall, this will do job:

            • sudo ufw allow 2222
          • @xMudrii Yes, I have opened port 2222.

            I believe this issue is server-side, as I am using port 22 to connect to the droplet on bitvise ssh.

      • @ryanpq I have just tried 8080 and it now returns this:

        $ ssh git.alexjamesbrown.me -p 8080
        ssh_exchange_identification: Connection closed by remote host
        
Have another answer? Share your knowledge.