It is very common, especially in companies, to have certain sites that have restricted access for some reason (sometimes absurd, sometimes not) , such as download sites, webmails and so on.
In general, these restrictions are made by blocking the domain of the site in question, also adding restrictions to certain ports. What do we do then if we need to obtain some information immediately?
Windows users typically use programs like PuTTY (which is also available on GNU/Linux) , or YourFreedom , but there is another, slightly more secure way to access sites that are blocked, using SSH and Sock5.
For this example, I'm assuming we have ports 80, 3128 (normally used for browsing) , and 9122 open, and we'll look at two real-world cases. The goal of this article isn't to explain in detail what SSH and Sock5 are and how they work; we'll leave that for another time. We'll look at two examples:
- Connecting to another PC by SSH using its IP address.
- Connecting to another PC by SSH using a domain (via DNS).
What do we need?
- A computer with Internet access that we can access by SSH.
- SSH installed of course.
- Corkscrew (in case we are behind a proxy).
We open a terminal and type (in the case of Debian) :
$ sudo aptitude install ssh corkscrew
OK .. I already installed. How do I connect?
It's very simple. Open a terminal and type ssh -p 443 user@ip_of_computer_with_internet :
ssh -p 9122 -D 1080 elav@192.168.1.1
The -p parameter, as you might expect, is used to specify which port we'll connect through. It's that simple. Now, open your browser's preferences (in my case, Firefox) and in Network Options , select only the option to use a Socks server and enter:
127.0.0.1:1080
This is enough to navigate.
What if we are behind a proxy?
It's possible that we might be behind a very restrictive proxy server or that our ISP simply won't allow us to connect via IP address, so we have to do it through DNS . This is where Corkscrew comes in . To use this application, all we have to do is create a file called config inside the .ssh folder in our /home directory using our favorite text editor.
$ vim ~/.ssh/config
and inside we put something like this:
host dominio.net
user tu_usuario
hostname dominio.net
port 9122
proxycommand corkscrew IP_Proxy 3128 %h %p
DynamicForward 1080
Compression yes
LocalForward 8888 localhost:8888
To explain this a bit. In the host parameter, we put the URL of the server we're going to connect to (which must have SSH available on port 9122 , as we saw in this post ). In the proxycommand parameter, after corkscrew, we put the IP address of our proxy or the FQDN , for example: proxy.domain.net , and the port used for browsing.
Now we just have to open a terminal and put:
ssh usuario@dominio.net
Now, one last detail. You might need to modify a setting in Firefox 's configuration if you don't have an internet connection. Open a new tab and type about:config . Promise not to mess with the settings and look for:
network.dns.disablePrefetch
And if it's set to false, we set it to true.