Pivoting Through Internal Networks with Sshuttle and Ligolo-ng

“Pivoting” is the method used to navigate throughout a network, by using a compromised “foothold” host to gain access to other internal networks and network components that otherwise wouldn’t have been accessible directly. In most networks, there will be various network segments that will contain different servers or devices of interest. It is therefore an extremely important skill to be able to “pivot” throughout a network to move laterally and gain deeper access into parts of a network that could contain sensitive or high-value systems.

Imagine you are presented with the following scenario on a network pentest. The network consists of different subnets, with only a single resource that is remotely accessible from the attacking Kali machine.

Internally, there are two different subnets that contain more sensitive or highly privileged servers, and the remotely accessible server has some level of access into the rest of the internal network. The basic overview of this setup might look something like the following:

Basic overview of the different resources that need to be accessed in a network pentest.

To perform the pentest and gain access to the green host, we will need to pivot throughout the network using both the blue and red hosts so that connection to this subnet can be established.

Pivoting is often done in a staged approach, as servers are compromised and further access into different subnets can be obtained. In this case access to the remotely accessible server needs to be gained first, then this server can be used to pivot into the subnet to compromise the server. From here, the subnet can be accessed by pivoting off the server, ultimately allowing for a connection to be made directly to the server.

This can be broken down as follows.

  • Stage 1 – Access and compromise the remotely accessible server (blue).
  • Stage 2 – Pivot into the subnet and compromise (red).
  • Stage 3 – Pivot into the subnet and compromise (green).

To accomplish this, two different tools will need to be used. These are Sshuttle and Ligolo-ng.


Sshuttle can be used to establish a VPN-like connection through to another subnet using SSH as the base connection.

When a remote server is dual homed and has access to an internal network, Sshuttle can be used to connect to that server and proxy all traffic from the attacker Kali machine through to the internal network.

In this example, the attacker Kali machine ( has access to the remote server ( which allows for SSH connections. This remote server also has access to an internal network subnet ( which we want to access to perform further enumeration and lateral movement. Sshuttle will allow us to make an SSH connection to this remote server and simultaneously tunnel a connection through to the internal network, providing remote access the internal resources in the subnet directly from our Kali machine.

This connection can be established using the following commands. If an SSH key is required to establish the SSH connection, use the second option. Otherwise, the first option will work when using a username and password combination for SSH authentication.

sshuttle -r user@
sshuttle -r user@ -e 'ssh -i /path/to/id_rsa'

The simple network overview diagram can be updated to look like the following:

Note that for Sshuttle to work, access to the remote server via SSH is required. This is often obtained by first compromising the remotely accessible server via an attack vector such as the web application (or other remotely accessible services).

Accessing Further Internal Networks

Sshuttle is extremely useful when accessing a single internal subnet via the intermediary “jump host” or “foothold” server. However, in some cases where even more internal jumps are required, internal servers may not have SSH running and chaining multiple Sshuttle sessions becomes fairly complex.

In this scenario, we need an easier method to establish connections to other internal network subnets which can then be accessed from the Kali testing machine.

To do this, we can use a tool called Ligolo-ng which will allow us to establish further remote VPN-esque tunnels by running lightweight agents that perform callbacks to our listening Kali machine.


Ligolo-ng is a tool that can be used to establish tunnels using reverse TCP/TLS connections directly over the tun interface. This tool is useful as it does not require the use of SOCKS proxies (and therefore does not require modifications to proxychains configurations like many other tools or pivoting techniques do). By running a Ligolo-ng agent on the remote machine, a connection can be made back to the attacker Kali machine and a tunnel is established. This allows all traffic types to be sent directly to the remote internal host.

Ligolo-ng requires a bit more set up initially, but is still easy and straightforward to use.

On our Kali Linux machine (, run the following commands to configure Ligolo-NG.
The final command should specify the subnet you are trying to access. In this case, the server we are trying to access is, so we specify the subnet we are trying to gain access to.

sudo ip tuntap add user root mode tun ligolo
sudo ip link set ligolo up
sudo ip route add dev ligolo

Then run the Proxy agent to start the Ligolo-NG listener on the Kali machine, this flag used here specifies the use of a self cert but this can be changed depending on the required configuration.

./proxy -selfcert

On the server which we have access to via SShuttle, upload the ‘agent.exe’ or ‘agent’ file depending on the OS and architecture of the server. Then, run the agent to connect back to the Kali Linux machine. The -ignore-cert can be used so that Ligolo-NG ignores certificate errors.

./agent.exe -connect -ignore-cert

On the Kali machine, there will be a Session picked up by the running Proxy agent listener. Interact with the Session using the ‘session’ command, then ‘start’ the tunnel through to the internal subnet.

This will then provide access to the subnet even further into an internal network. Ligolo-NG works like a VPN tunnel, so once the session is established and the tunnel is started there is no further need for configuration, all tools or scripts can be pointed at the internal resources such as the server

The Ligolo-ng section of the simple network overview can be illustrated by the following:


Putting this all together, here is a full overview of what this might look like when using Sshuttle and Ligolo-ng. The initial connection to the host is made using Sshuttle, and then the Ligolo-ng agent is run on this host to provide a second tunnel directly to the subnet that the host is sitting on.

Once this is configured, we will have access to two different internal subnets ( and to progress the pentest and gain full access to the internal network.

Full diagram of how these resources can be accessed using Sshuttle and Ligolo-ng




One thought on “Pivoting Through Internal Networks with Sshuttle and Ligolo-ng

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s