Thursday, February 21, 2008

How to use ssh through a proxy in Ubuntu

This time i had to connect through an http proxy to other machines using ssh, this took me some investigation, mather that i like ;-)

First i downloaded the connect-proxy package, the source code is also available but i had problems while compiling it, so i downloaded it from here:
http://archive.ubuntu.com/ubuntu/pool/universe/c/connect-proxy/connect-proxy_1.95-3_i386.deb

I had to download it withe Firefox, because i was behind a proxy and do not had still the possibility to download other ways. wget probably accepts a proxy argument, but i used the fastest way.

Then, i installed it:
dpkg -i /home/walter/connect-proxy_1.95-3_i386.deb

Then, create a file ~/.ssh/config, whit this:
---
Host *
ProxyCommand connect-proxy -H proxy2.your.proxy.com:8080 %h %p
---

Finally, test the connection:
ssh -F .ssh/config mysite.argentina.com.ar -p 2210

And i did a tunnel to another application:
ssh -F .ssh/config -g -L 8000:192.168.2.1:2211 mysite.argentina.com.ar -p 2210

For more information about how to do a tunnel, see my previous post:
Secure Tunnel

1 comentarios:

Juan M. Docile said...

Hi Walter, how do you do?

Look at this...

FATAL: failed to begin relaying via HTTP.
ssh_exchange_identification: Connection closed by remote host

The proxy in my company don't allow me to create the connection ?

Regards

Juan M.