Web development and useful information

Nathan's Blog

Using Git on port 443 through a proxy

Internet access at work goes through a proxy and firewall. The proxy allows connections out on port 80 (HTTP) and 443 (HTTPS) only. I needed to install Git for Windows (msysgit – 1.7.9) on my Windows 7 PC and two Windows 2008 servers.

I followed these instructions and installed Git, set up my SSH keys, passphrase and added my public key to GitHub. I then tried to SSH to GitHub using: ssh -T git@github.com and because port 22 is blocked it failed to connect, returning the error message:

ssh: connect to host github.com port 22: Bad file number

To make Git work on Windows, through port 443 and a HTTP proxy server – with proxy authentication (Intergrated) – the following worked for me:

  1. Create a new file named config inside your ~/.ssh/ folder.
    This is usually located here: C:\Users\USERNAME\.ssh\
  2. Paste the following code into your config file.
    ProxyCommand connect.exe -H proxy_user@proxy_server:proxy_port %h %p
    Host github.com
    User git
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 44

    Update the ProxyCommand values:

    proxy_user: your proxy username
    proxy_server: your proxy server
    proxy_port: your proxy port

    %h and %p will be replaced on invoking proxy command with the target hostname and port specified to the SSH command.

Creating this config file allowed me to successfully connect to GitHub at work.
I do have to authenticate with my proxy password every time I connect though. If you know a secure way to store the proxy password please comment.

Thanks to Sam vdb’s answer on stackoverflow and @skim’s blog post here for the solution.

Recently Loved Web Articles


How to know the day a date falls on


Upgrading to Moodle 2.3

1 Comment

  1. Pete

    If you're gitting from Windows on a work network and you are unable to access external resources due to a port 443 connection error then you can also try these steps.
    Get the details of your work proxy url (there should be one) e.g. "http//:www-mywork-proxy:80"
    create the following windows system variables give each of them the proxy url as their value:
    Re try your git clone or whatever it is you were doing.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress & Theme by Anders Norén