{"id":495,"date":"2012-03-29T17:46:21","date_gmt":"2012-03-29T16:46:21","guid":{"rendered":"http:\/\/www.nathankowald.com\/blog\/?p=495"},"modified":"2016-11-13T17:55:06","modified_gmt":"2016-11-13T17:55:06","slug":"github-on-port-443-through-a-proxy","status":"publish","type":"post","link":"https:\/\/www.nathankowald.com\/blog\/2012\/03\/github-on-port-443-through-a-proxy\/","title":{"rendered":"Using Git on port 443 through a proxy"},"content":{"rendered":"<p>Internet access at work goes through a proxy and firewall. The proxy allows connections out on port 80 (HTTP) and 443 (HTTPS) only.\u00a0I needed to install Git for Windows (msysgit &#8211;\u00a01.7.9) on my Windows 7 PC and two Windows 2008 servers.<\/p>\n<p>I followed\u00a0<a title=\"these instructions\" href=\"http:\/\/help.github.com\/win-set-up-git\/\" target=\"_blank\">these instructions<\/a>\u00a0and installed Git, set up my SSH keys, passphrase and added my public key to GitHub. I then tried to SSH to GitHub using: <code>ssh -T git@github.com<\/code> and because port 22 is blocked it failed to connect, returning the error message:<\/p>\n<pre class=\"prettyprint lang-sh\">ssh: connect to host github.com port 22: Bad file number<\/pre>\n<p>To make Git work on Windows, through port 443 and a HTTP proxy server &#8211; with proxy authentication (Intergrated) &#8211; the following worked for me:<\/p>\n<ol>\n<li>Create a new file named <strong>config<\/strong> inside your <strong>~\/.ssh\/<\/strong> folder.<br \/>\nThis is usually located here:\u00a0<strong>C:\\Users\\USERNAME\\.ssh\\<\/strong><\/li>\n<li>Paste the following code into your <strong>config<\/strong> file.\n<pre class=\"prettyprint lang-sh\">\r\nProxyCommand connect.exe -H proxy_user@proxy_server:proxy_port %h %p\r\n\r\nHost github.com\r\nUser git\r\nHostname ssh.github.com\r\nPreferredAuthentications publickey\r\nIdentityFile ~\/.ssh\/id_rsa\r\nPort 44<\/pre>\n<p>Update the ProxyCommand values:<\/p>\n<p><strong>proxy_user:<\/strong> your proxy username<br \/>\n<strong>proxy_server:<\/strong> your proxy server<br \/>\n<strong>proxy_port:<\/strong> your proxy port<\/p>\n<p><strong>%h<\/strong> and <strong>%p<\/strong> will be replaced on invoking proxy command with the target hostname and port specified to the SSH command.<\/li>\n<\/ol>\n<p>Creating this config file allowed me to successfully connect to GitHub at work.<br \/>\nI 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.<\/p>\n<p>Thanks to <a href=\"http:\/\/stackoverflow.com\/questions\/7144811\/git-ssh-problem-bad-file-number\/8019448#8019448\" target=\"_blank\">Sam vdb&#8217;s answer<\/a> on stackoverflow and <a href=\"http:\/\/twitter.com\/skim\" target=\"_blank\">@skim&#8217;<\/a>s <a href=\"http:\/\/skim.la\/2010\/02\/22\/how-to-make-github-and-proxy-play-nicely-with-ssh\/\" target=\"_blank\">blog post here<\/a> for the solution.<\/p>\n<hr \/>\n<h3>Recently Loved Web Articles <a href=\"http:\/\/del.icio.us\/rss\/n8kowald\/shared\"><img decoding=\"async\" class=\"noborder\" title=\"Subscribe to my loved articles feed\" src=\"\/\/www.nathankowald.com\/images\/feed-small.png\" alt=\"\" \/><\/a><\/h3>\n<ul class=\"lovedarticles\">\n<li><a href=\"http:\/\/www.techrepublic.com\/blog\/window-on-windows\/change-and-customize-windows-7s-logon-screen-wallpaper\/2135\">Change and customize Windows 7&#8217;s Logon screen wallpaper | TechRepublic<\/a><\/li>\n<li><a href=\"http:\/\/claudiorodval.deviantart.com\/\">claudiorodval on deviantART<\/a> &#8211; <em>Great illustrations<\/em><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/q\/7144811\">git ssh problem bad file number &#8211; Stack Overflow<\/a> &#8211; <em>Solution to running Git on Windows where SSH port 22 is blocked. Add a config file.<\/em><\/li>\n<li><a href=\"http:\/\/lxr.php.net\/xref\/PHP_5_4\/\">Cross Reference: \/PHP_5_4<\/a> &#8211; <em>View the C code for PHP functions. Usage: &#8220;PHP_FUNCTION strpos&#8221;<\/em><\/li>\n<li><a href=\"http:\/\/vimeo.com\/36863220\">Codercat Time Lapse on Vimeo<\/a> &#8211; <em>Love this!<\/em><\/li>\n<li><a href=\"http:\/\/goosh.org\/\">goosh.org &#8211; the unofficial google shell.<\/a> &#8211; <em>Text-only version of Google<\/em><\/li>\n<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/Ben_Franklin_effect\">Ben Franklin effect &#8211; Wikipedia, the free encyclopedia<\/a> &#8211; <em>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.<\/em><\/li>\n<li><a href=\"http:\/\/www.eurodroid.com\/2012\/03\/13\/galaxy-s-ii-android-4-0-update-hitting-uk-android-users-from-march-19th\/\">Galaxy S II Android 4.0 update hitting UK Android users from March 19th | Eurodroid<\/a><\/li>\n<li><a href=\"http:\/\/www.catonmat.net\/blog\/why-vim-uses-hjkl-as-arrow-keys\/\">Here is why vim uses the hjkl keys as arrow keys &#8211; good coders code, great reuse<\/a><\/li>\n<li><a href=\"http:\/\/moviesascode.net\/\">Movies as code &#8211; Free your coding mind<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Internet access at work goes through a proxy and firewall. The proxy allows connections out on port 80 (HTTP) and 443 (HTTPS) only.\u00a0I needed to install Git for Windows (msysgit &#8211;\u00a01.7.9) on my Windows 7 PC and two Windows 2008 servers. I followed\u00a0these instructions\u00a0and installed Git, set up my SSH keys, passphrase and added my [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[13,7],"tags":[],"class_list":["post-495","post","type-post","status-publish","format-standard","hentry","category-git","category-web-development"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/comments?post=495"}],"version-history":[{"count":81,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/495\/revisions"}],"predecessor-version":[{"id":1788,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/495\/revisions\/1788"}],"wp:attachment":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/media?parent=495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/categories?post=495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/tags?post=495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}