By writing this I am assuming you know what SOCKS is, and you know what SSH is. If you don’t, here is a picture of a monkey fucking a coconut to make this visit worth your while:

Could be a melon, but looks like a co-co-nut.
So, there comes a time in a man’s life when people at work on the inside network need to access things on the internet. This is called “proxying”. Yes, yes, I know; very fascinating. These secure machines on the inside network don’t have access to the internet by design (See RFC 1918). It’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.
Ok so we want to let our secure hosts on the inside proxy SSH to the internet via our SOCKS server.
Assumptions:
Create an entry in ~/.ssh/config. If this file doesn’t exist, create it. If it does, add this shit to the bottom:
Host proxythatshit
ProxyCommand /usr/bin/nc -X 5 -x proxy.whatever.com:1080 internet.com 22
Write, quit, and then test that shit! I am hoping that you gathered “proxythatshit” is the nickname we’re assigning this proxied connection to internet.com. By putting this stuff in the config file, it makes it easy to reuse.
% ssh proxythatshit jathan@proxythatshit's password: [jathan@internet.com]~%Did you see that? It worked!! OMGZ!!JLk
A little breakdown:
ProxyCommand /usr/bin/nc -X 5 -x proxy.whatever.com:1080 internet.com 22
You may be asking yourself, “Why not just use an HTTP proxy?” 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’t HTTP (such as this SSH proxy thing) on anything other than port 80, 443, or 8080 it probably won’t work. If you’re using mod_proxy, it absolutely will not work. Don’t ask me why. It just doesn’t. Squid might work, but it is a pain in the ass to setup.
There you have it. Don’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.
June 15th, 2010 at 06:56
I searched for a thing entirely diverse, but discovered your web site! And ought to say thanks. Wonderful examine. Will arrive back again.