logos

With Andrii Grytsenko


Technical Diary - With Andrii Grytsenko

How to get fully internet functionality from restricted environment over ssh

If you working place don’t provide internet or provide very restricted access to web pages. But you want to feel free in the internet browsing.

For this you need:
1. At least one open port for output connection OR access to proxy.
2. Server in the internet with root OR user rights.

You can easily get it in several simple steps. Just imagine that you located at office1 and open port for ongoing connection = 443. Also you have access to server1 which located at internet. Now go to server1 and edit ssh configuration file. Add new port directive into this file(in case if you have open port, in other case skip this step). Like this:

server1# grep -i port /etc/ssh/sshd_config
Port 22
Port 443

As you can see now server1 use 2 ports(22 and 443) for ssh daemon. Let’s check it:

server1# netstat -lnp | grep ssh
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3946/sshd
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      3946/sshd

It’s ok. The next step #2 install proxy server. You can choose anyone you like. I chose tinyproxy, because of it’s very small and simple in configuration.

server1# apt-get install tinyproxy 

It’s valid command for debian. For your distro use distro specific package manager as well.

Go to /etc/tinyproxy/tinyproxy.conf and check port and listen directives for determinate on which port and address your proxy listen. In my case it’s port 8888 on localhost:

server1#grep -E "^(Port|Listen)"  /etc/tinyproxy/tinyproxy.conf
Port 8888
Listen 127.0.0.1

Start daemon and check that it run:

server1# /etc/init.d/tinyproxy start
server1# netstat -lnp | grep tinyproxy
tcp        0      127.0.0.1:8888              0.0.0.0:*               LISTEN      3923/tinyproxy

Looks fine. Now make ssh tunnel to your server. If you have direct connection to server. Use this :

server1#ssh -p 443 user@server#1 -L8888:127.0.0.01:8888 

If not then do as described here.

And last one step is setting up proxy 127.0.0.1:8888 on your browser and enjoy.

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Categories

Translate