31 October 2015

Easily SSH Tunneling in Any Linux Distribution by Using Proxychains


SSH Tunneling is a tricky way to connect to internet network. Theoretically, SSH Tunneling is a mechanism to connect to internet network by "riding" other connection's band. In Windows, there are plenty applications and or tools to use SSH tunneling.

How about Linux desktop?
SSH itself is a tool from Linux world. Thus, SSH Tunneling of course easily can be done in ANY Linux distribution, without ANY third party applications. All you need is ssh command and a tiny tool called proxychains.

Purpose
SSH tunneling commonly used to bypass regular connection to others' private connection, in order, for example, we could access blocked websites (youtube, porn site, etc). Another common purpose of SSH tunneling is to pursue better internet connection speed.

Steps

1. Open terminal and run following command :

ssh -D 12345 user@yourserver.com/your server's IP -p server_port

Example :

ssh -D 12345 andy@192.168.11.99 -p 22

Once you're logged in into your server, don't close Terminal.

2. Install Proxychains

sudo apt-get install proxychains

3. Configure proxychains

sudo gedit /etc/proxychains.conf (use your favorite text editor)


Find the line :
socks4     127.0.0.1 9050
and change the port with our new port 12345 to be like this :
socks4     127.0.0.1 12345
Save the file and exit.

Usage
To use the proxy we've been made, we need to use proxychains in front of any command. Example :

sudo proxychains apt-get update
sudo proxychains apt-get install xxxx xxxx xxxx

Desktop Applications
For desktop applications like Google Chrome, you can edit the shortcut. Example :

sudo gedit /usr/share/applications/google-chrome.desktop

Find the line :

Exec=/usr/bin/google-chrome-stable --incognito

And add proxychains in front of executable command, to be like this :

Exec=proxychains /usr/bin/google-chrome-stable --incognito

Save the file and exit.


GNOME and MATE Users

If you are using GNOME or MATE based Linux distributions, you could easily enable SSH Tunneling proxy in Network Setting. Enter this value :

Sock Host : localhost Port 12345


But still, if you need to use the proxy in command line interface, you still need to use proychains.


No comments: