The Lumber Room

"Consign them to dust and damp by way of preserving them"

Archive for December 19th, 2006

ssh through a proxy (Squid, etc)

with one comment

If you are somewhere where the only way of connecting to the outside world is through a proxy, then to get ssh to work, here’s what to do:

Get connect.c.

Compile it (gcc connect.c -o connect), and put connect somewhere in your path. That page says /usr/local/bin, but you probably don’t have permissions to that, anyway. You can do mkdir -p ~/bin && mv connect ~/bin and add a line export PATH=$PATH:~/bin to ~/.bashrc or ~/.bash_profile (or both), and restart the terminal, or start a new one.

Edit the file ~/.ssh/config (create it if it doesn’t exist) and add the two lines

Host *
  ProxyCommand connect -H proxyusername@proxyname:3128 %h %p

Replace proxyusername by the username for the proxy, and proxyname by the location of the proxy, and 3128 by the port number (it’s usually 3128 for Squid).

If it is a low-security thing and the password is already well-known (guest account?), then might as well put the password in the above .bash… files, to save the hassle of typing it each time:
export HTTP_PROXY_PASSWORD=proxypassword

Then ssh should work as usual: ssh username@hostname , etc.

Written by S

Tue, 2006-12-19 at 13:40:58

Posted in compknow