Search code examples
gitsshport

Custom SSH Config Not Working


I have been trying to get ssh to connect to Github using port 443 and I have decided to use a custom ssh config file at ~/.ssh/config. After creating the file and setting the proper file permissions I attempt to connect again, the connection is still timing out on port 22. I know this because port 22 is blocked by my ISP (for some strange reason).

$ cd ~/.ssh
$ touch config
$ chown $USER config
$ chmod 644 config

Then in the config file I add this:

Host pagodabox.io
  HostName git.pagodabox.io
  Port 443

Host github.com
  HostName ssh.github.com
  Port 443

Then I attempt to call this from my iTerm app.

$ ssh -T git@ssh.github.com

I get the error:

ssh: connect to host ssh.github.com port 22: Operation timed out fatal: Could not read from remote repository.

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

However, if I do this

$ ssh -T -p 443 git@ssh.github.com 

I get the desired response.

Hi [Username]! You've successfully authenticated, but GitHub does not provide shell access.

I am using oh-my-zsh FWIW. Why is this happening? I have rebooted my mac also. Still the file doesn't seem to be recognised


Solution

  • You wrote:

     Host github.com
       HostName ssh.github.com
       Port 443
    

    But didn't use it:

     ssh -T git@ssh.github.com
    

    You need to

     ssh -T git@github.com
    

    to use the github.com host you defined.


    Alternatively, add ssh.github.com as another name to match:

     Host github.com ssh.github.com
       HostName ssh.github.com
       Port 443