sshwifigitlab

GitLab (SSH) via public WIFI, port 22 blocked


I am using Starbucks wifi and I get the following when trying to push to a gitlab.com repo:

  $ git push origin master
  ssh: connect to host gitlab.com port 22: Connection refused
  fatal: Could not read from remote repository.

I tried adapting a workaround for GitHub: Github (SSH) via public WIFI, port 22 blocked by adding the following to ~/.ssh/config

 Host gitlab.com
        Hostname gitlab.com
        Port 443

But that doesn't work as I get this error:

 $ git push origin master
 ssh_exchange_identification: Connection closed by remote host
 fatal: Could not read from remote repository.

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

I there a workaround that will allow me to push to GitLab.com using port 443?


Solution

  • Thanks to @oleg-gopkolov for giving me the hint to try defining the origin differently! It turns out ssh port 443 didn't work but https did as per below.

    How to switch origin to https so that pushing to gitlab.com works while on on Starbucks wifi

    Here are the commands to switch to https (if you had experimented with other changes and your local is out of date like mine was you will also need to follow Cannot push to GitHub - keeps saying need merge ):

    git remote remove origin
    git remote add origin https://gitlab.com/your_username/your_repo.git
    git push --set-upstream origin master
    

    If you want to do some testing on a fresh checkout

    It turns out that using the https checkout option does work. So provided you don't mind a fresh checkout, you can run this on Starbucks wifi:

    git clone https://gitlab.com/your_username/your_repo.git
    

    Then to test committing you can edit README.md and then run:

      git commit README.md
      git push
    

    If you want to confirm that SSH GitLab access doesn't work on Starbucks wifi

    To confirm that SSH cloning does not work at Starbucks you can run one of the following 3 commands:

    git clone git@gitlab.com:your_username/your_repo.git
    git clone git@gitlab.com:443/your_username/your_repo.git
    git clone ssh://gitlab.com:443your_username/your_repo.git
    

    And for each one you will get an error like this:

    Cloning into 'your_repo'...
    ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.