Tunneling SSH over a Proxy Server

200px-Squid-cache_logo

Download corkscrew from this site

http://www.agroman.net/corkscrew/

Unpack and compile corkscrew

tar -xzvf corkscrew.tar.gz
cd corkscrew
./configure
make install 

Now create a file in .ssh folder

touch ~/.ssh/config

Now edit that file

vim ~/.ssh/config

and add these lines inside config file

Host *
  ProxyCommand corkscrew http-proxy.example.com 8080 %h %p

Replace http-proxy.example.com with the name or address of your http proxy and possibly replacing 8080 with the port on which the proxy listens, which may be 80 or even some other port. The %h and %p will be replaced automatically by SSH with the actual destination host and port.

Now try ssh

ssh user@someserver.org

replace user and some server with yours.If you are getting an error like this then your proxy needs authentication

ssh_exchange_identification: Connection closed by remote host
[ OR ]
ssh: connection to host example.net port 22: Connection timed out 

Authenticated proxy connections
create a file on .ssh

touch ~/.ssh/proxyauth

edit that file and give your usrname and password like this

<username>:<passwd>

Then change your config file inside ssh with proxyauth

Host *
  ProxyCommand corkscrew http-proxy.example.com 8080 %h %p ~/.ssh/proxyauth

Happy Hacking 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s