title: gitlab connection refused ssh port 22 and 443
body: <p>For the last couple of days I have been unable to push to the remote (gitlab), it has worked before this. I know this question has 10s of similar SO questions and perhaps an answer is somewhere in those. However I have been trying many of the suggested solutions - in vain.</p>
  
  <ul>
  <li><p>When I push I get: </p>
  
  <p><code>ssh: connect to host gitlab.com port 22: Connection refused 
  fatal: The remote end hung up unexpectedly</code></p></li>
  <li><p>The local is on a constitutional server and many people here are using port 22 mostly for github with no problems. Is it possible that this is a firewall setting on my side that could be related to gitlab specifically? The administrator ensures that it is not a simple whitelist issue.  </p></li>
  <li><p>My gitlab url is as: </p>
  
  <p><code>origin  git@gitlab.com:myname/myproject.git (fetch) 
  origin  git@gitlab.com:myname/myproject.git (push)</code></p></li>
  <li><p>I have tried to update the git-url with the alternative ssh format:</p>
  
  <p><code>origin  ssh://git@gitlab.com/myname/myproject.git (fetch)
  origin  ssh://git@gitlab.com/myname/myproject.git (push)</code></p></li>
  <li><p>I have tried both port 22 and the alternative 443 - this is the <code>~/.ssh/config</code> file:</p>
  
  <p><code>Host gitlab.com 
  RSAAuthentication yes 
  IdentityFile ~/.ssh/id_rsa</code></p></li>
  <li><p>Alternative: </p>
  
  <p><code>Host gitlab.com 
  Hostname altssh.gitlab.com 
  User git 
  Port 443 
  PreferredAuthentications publickey 
  IdentityFile ~/.ssh/id_rsa</code></p></li>
  <li><p>I have tried to use https connection (in vain).</p></li>
  <li><p>Made new ssh keys (in vain).</p></li>
  </ul>
  
  <p>I am lost with things to try and my branch is ahead of origin by a lot of commits.
  Am I missing something simple here to try out ?.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>When removing ~/.ssh/config and issuing <code>ssh -Tv git@gitlab.com</code> it still does not work - I get:</p>
  
  <pre><code>OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
  debug1: Reading configuration data /etc/ssh/ssh_config
  debug1: Applying options for *
  debug1: Connecting to gitlab.com [52.167.219.168] port 22.
  debug1: connect to address 52.167.219.168 port 22: Connection refused
  ssh: connect to host gitlab.com port 22: Connection refused
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  So it turns out that our institutional server does not whitelist gitlab.com because they - in contrast to, say, github.com, does not provide an official IP address range. My solution was to make a mount point from my workstation computer to the server containing my project, and then push/pull the git directory via the computer.  </p>