Thursday Night

Paul Betts’s personal website / blog / what-have-you

Getting SSH to connect through a SOCKS proxy

2 comments

At work, one of the things that has never worked for me is being able to use SSH from my laptop. While Cocoa apps will get redirected properly, command-line apps try to directly connect and fail. I’ve been trying for months to fix it, but could never find any solution that worked. The problem is compounded by the fact that the tool to fix it is not very searchable, and doesn’t compile on OS X.

However, I now have the solution:

  1. Download connect-proxy.tar.bz2 from my website (which is a patched, compiled version of the Debian package), and unpack the archive
  2. If you’re on OS X, just copy “connect-proxy” to your /usr/local/bin, otherwise run “make clean && make”, then copy the file
  3. Go to your “~/.ssh” folder and create a file called config. Insert the following line:

    Host *
    ProxyCommand connect-proxy -R both -4 -S proxy.url:1080 %h %p

And now, you’re good to go! But what do those flags do? Here’s a description of some useful flags:

  • “-R both” – try a DNS lookup directly, and if it fails, try asking the proxy server
  • “-4/-5″ – SOCKS4/SOCKS5
  • “-S/-H hostname:port” – SOCKS / HTTP-based proxy
  • “-d” – Causes connect-proxy to spew out debugging information

Written by Paul Betts

April 8th, 2008 at 3:30 pm

Posted in Apple, Linux

2 Responses to 'Getting SSH to connect through a SOCKS proxy'

Subscribe to comments with RSS or TrackBack to 'Getting SSH to connect through a SOCKS proxy'.

  1. You’ve got wrong url under “tool to fix it” link.
    Thanks for a tip :-) .

    Pev

    6 May 08 at 4:21 am

  2. This is exactly what I need. But I got only a “cannot execute binary file” on a MacOS V 10.4.11 (PowerPC)
    Did you have a hint?
    thomas

    Thomas

    30 Jul 08 at 5:59 am

Leave a Reply