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:
- Create a new file named config inside your ~/.ssh/ folder.
This is usually located here: C:\Users\USERNAME\.ssh\ - 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
- Change and customize Windows 7’s Logon screen wallpaper | TechRepublic
- claudiorodval on deviantART – Great illustrations
- git ssh problem bad file number – Stack Overflow – Solution to running Git on Windows where SSH port 22 is blocked. Add a config file.
- Cross Reference: /PHP_5_4 – View the C code for PHP functions. Usage: “PHP_FUNCTION strpos”
- Codercat Time Lapse on Vimeo – Love this!
- goosh.org – the unofficial google shell. – Text-only version of Google
- Ben Franklin effect – Wikipedia, the free encyclopedia – The Ben Franklin effect is a psychological finding: A person who has done someone a favor is more likely to do that person another favor than they would be if they had received a favor from that person. Similarly, one who harms another is more willing to harm them again than the victim is to retaliate.
- Galaxy S II Android 4.0 update hitting UK Android users from March 19th | Eurodroid
- Here is why vim uses the hjkl keys as arrow keys – good coders code, great reuse
- Movies as code – Free your coding mind
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:
HTTP_PROXY
HTTPS_PROXY
Save
Re try your git clone or whatever it is you were doing.