Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apt-get install via tunnel proxy but ssh only from client side

So... this is my problem:

I can access to a VPN from my machine. I can access to a server in the VPN via SSH, but this machine has no access inside out because a firewall is blocking the reverse ssh connections. So I can't use Internet via tunnel to use apt-get.

Lan configuration

How can I emulate:

sudo ssh -D 9999 root@<machineoutsidevpn>

But from outside the VPN. Or any way to use the Internet connection to install packages?

like image 855
rasputino Avatar asked Apr 01 '16 10:04

rasputino


People also ask

Does SSH go through proxy?

You need an SSH client that can issue CONNECT requests through the company HTTP proxy. If you're on Windows, using Putty is fine as it has built-in support for tunneling through a HTTP proxy. If you're on unix/linux (or cywgin) you can use openssh with corkscrew to go through the proxy to your home computer's port 443.

Is SSH tunnel two way?

With Two-Way SSH tunnel you can connect to any destination under a single condition, which is, the ability to ssh login from the destination to the source. If you can do that, you can as well reverse login from source to destination even if it is behind firewall or NAT.


1 Answers

Setup:

Computer A

  • Has access to Internet
  • Has access to Computer B
  • SSH is installed

Computer B

  • Doesn't have access to Internet
  • OpenSSH Server is installed

Steps:

  1. ssh into Computer B from Computer A

    sudo ssh -R <selected port>:us.archive.ubuntu.com:80 [email protected]
    
  2. Edit Computer B's /etc/apt/apt.conf to include the following lines:

    Acquire::http::Proxy "http://localhost:<selected port>";
    Acquire::https::Proxy "https://localhost:<selected port>";
    
  3. Run your apt-get update or install or upgrade on Computer B and it should work.


A few notes:

  • You HAVE to keep the original session of ssh from Computer A to Computer B active while using Computer B to access apt-get repositories.
  • You DON'T have to use the same ssh connection to utilize the tunnel (meaning if you have multiple ssh connection into Computer B, they should all work)

Using Putty

This can also be achieved using Putty (assuming that Computer A is the Windows machine).

  1. When starting the session, select SSH --> Tunnels
  2. Source Port: <selected port>
  3. Destination: us.archive.ubuntu.com:80
  4. Select the "Remote" radio button
  5. Select "Add" button
  6. Configure your session as you normally would.
  7. Follow steps 2 & 3 above
like image 140
James Mertz Avatar answered Oct 10 '22 12:10

James Mertz