How to connect to Internet an isolated server using Squid….

LobuhiSec
2 min readMay 28, 2020

…and then you can run apt, git, curl, pip or wget.

Recently I’ve been facing an Internal test on which my jump server is a virtual image for this purpose, but it’s not even updated and maybe I would need to install an specific library from apt or a git repo.

So my environment is something like this:

Note that I need to connect to this environment using a VPN service cause it just works as a local network.

All I need is just apt and git so HTTP protocol will fit in my case.

First of all install squid on your side or anywhere you have an Internet connection and follow this steps:

sudo apt install squid
sudo vi /etc/squid/squid.conf

Then search line http_access deny all and replace it by http_access allow all.

Then restart the service:

sudo service squid restart

Squid will be running by default on port 3128/tcp.

Now you can connect to SSH server:

ssh -R 3129:localhost:3128 user@10.0.0.2

Once you’re logged in you’ll need to configure the default proxy for your system, adding this lines to /etc/environment

export http_proxy=http://127.0.0.1:3129
export https_proxy=http://127.0.0.1:3129

Then go back to your shell and run:

source /etc/environment

Ready! Now you can curl or wget anything on Internet, but you’ll notice early that apt won’t work at all.

Once again, you need to configure a last thing to “proxify” apt.

Open/create this non-existent file:

sudo vi /etc/apt/apt.conf.d/proxy.conf

Add this lines on it:

Acquire::http::Proxy "http://localhost:3129/";
Acquire::https::Proxy "http://localhost:3129/";

Et voilà! We’re already online and apt working!

Sources:

--

--