<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jathanism &#187; proxy</title>
	<atom:link href="http://jathan.com/tag/proxy/feed/" rel="self" type="application/rss+xml" />
	<link>http://jathan.com</link>
	<description>computers, robots, and other cool things.</description>
	<lastBuildDate>Thu, 20 Oct 2011 01:50:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Proxying SSH with SOCKS (HTTP was so 2007)</title>
		<link>http://jathan.com/2009/07/30/proxying-ssh-with-socks-http-was-so-2007/</link>
		<comments>http://jathan.com/2009/07/30/proxying-ssh-with-socks-http-was-so-2007/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 23:07:18 +0000</pubDate>
		<dc:creator>jathan</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[coconut]]></category>
		<category><![CDATA[fucking]]></category>
		<category><![CDATA[monkey]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jathan.com/?p=39</guid>
		<description><![CDATA[By writing this I am assuming you know what SOCKS is, and you know what SSH is. If you don&#8217;t, here is a picture of a monkey fucking a coconut to make this visit worth your while: So, there comes a time in a man&#8217;s life when people at work on the inside network need [...]]]></description>
			<content:encoded><![CDATA[<p>By writing this I am assuming you know what <a href="http://en.wikipedia.org/wiki/SOCKS" target="_blank">SOCKS</a> is, and you know what <a href="http://en.wikipedia.org/wiki/Secure_Shell" target="_blank">SSH</a> is. If you don&#8217;t, here is a picture of a monkey fucking a coconut to make this visit worth your while:</p>

<div class="wp-caption alignright" style="width: 191px"><img title="MFC? Is that you?" src="http://i14.photobucket.com/albums/a346/Gargamel198024/monkeyfuckingacoconut.gif" alt="Could be a melon, but looks like a co-co-nut." width="181" height="161" /><p class="wp-caption-text">Could be a melon, but looks like a co-co-nut.</p></div>

<p>So, there comes a time in a man&#8217;s life when people at work on the inside network need to access things on the internet.  This is called &#8220;proxying&#8221;.  Yes, yes, I know; very fascinating.  These secure machines on the inside network don&#8217;t have access to the internet by design (See <a href="http://en.wikipedia.org/wiki/Private_network" target="_blank">RFC 1918</a>).  It&#8217;s the most basic layer of obfuscation (a 25 cent word we use a lot in the security world) and protection from bad internet traffic, not including firewalls and all that other exciting stuff.</p>

<p>Ok so we want to let our secure hosts on the inside proxy SSH to the internet via our SOCKS server.</p>

<p><strong>Assumptions:</strong>
<ul>
    <li>A Unix/Linux machine with the latest version of <a href="http://en.wikipedia.org/wiki/Netcat" target="_blank">netcat</a> installed (assumed to be found at <tt>/usr/bin/nc</tt>).  All modern operating systems have this.  Stop whining.</li>
    <li>A SOCKS proxy listening on TCP port 1080.</li>
    <li>A remote internet server listening for SSH connections on TCP port 22.</li>
    <li>You know what <tt>~</tt> means.  (Hint:  It&#8217;s shorthand for your home directory.)</li>
</ul>
<strong>Do the damn thing:</strong></p>

<p>Create an entry in <tt>~/.ssh/config</tt>.  If this file doesn&#8217;t exist, create it.  If it does, add this shit to the bottom:
<pre>Host proxythatshit
    ProxyCommand /usr/bin/nc -X 5 -x proxy.whatever.com:1080 internet.com 22</pre>
Write, quit, and then test that shit!  I am hoping that you gathered &#8220;proxythatshit&#8221; is the nickname we&#8217;re assigning this proxied connection to <em>internet.com</em>.  By putting this stuff in the config file, it makes it easy to reuse.
<pre>% ssh proxythatshit
jathan@proxythatshit's password:
[jathan@internet.com]~%</pre>
Did you see that?  It worked!! OMGZ!!JLk</p>

<p><strong>A little breakdown:</strong></p>

<p><tt>ProxyCommand /usr/bin/nc -X 5 -x proxy.whatever.com:1080 internet.com 22</tt>
<ul>
    <li><strong>ProxyCommand:</strong> An OpenSSH directive that tells SSH how to proxy the connection</li>
    <li><strong>/usr/bin/nc:</strong> The path to the netcat binary and the ProxyCommand in question here.  Proxying is one of the many things netcat does.</li>
    <li><strong>-X 5</strong>: Tells netcat to use SOCKS version 5</li>
    <li><strong>-x proxy.whatever.com:1080</strong>: Tells netcat to proxy the connection using <em>proxy.whatever.com</em> on port 1080</li>
    <li><strong>internet.com 22</strong>: The name and port of the destination we&#8217;re trying to get to by way of the proxy</li>
</ul>
<strong>Why SOCKS?</strong></p>

<p>You may be asking yourself, &#8220;Why not just use an HTTP proxy?&#8221;  Because HTTP proxies tend to be very picky about allowing you to proxy non-HTTP connections to destination ports other than the one you connected to.  In other words, if the proxy is listening on port 8080, good luck proxying a connection that isn&#8217;t HTTP (such as this SSH proxy thing) on anything other than port 80, 443, or 8080 it probably won&#8217;t work. If you&#8217;re using <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html" target="_blank">mod_proxy</a>, it absolutely will not work.  Don&#8217;t ask me why.  It just doesn&#8217;t.  <a href="http://www.squid-cache.org/" target="_blank">Squid</a> might work, but it is a pain in the ass to setup.</p>

<p>There you have it.  Don&#8217;t blame me if you get fired because you were looking at a picture of a monkey fucking a coconut for the 52 seconds it took to read this.</p>
]]></content:encoded>
			<wfw:commentRss>http://jathan.com/2009/07/30/proxying-ssh-with-socks-http-was-so-2007/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

