An alternative to SSH tunneling to access internal machines through gateway is using jump hosts.
A jump host (also known as a jump server) is an intermediary host or an SSH gateway to a remote network, through which a connection can be made to another host in a dissimilar security zone
There are many reasons to use a jump server. For example, Jump servers are often placed between a secure zone and a DMZ. These jump servers provide for the transparent management of devices within the DMZ, as well as a single point of entry.
But how can you set this up? I’m going to show you how to create a simple jump with the following details :
- Originating IP: 192.168.1.10
- Jump IP (machine_a): 192.168.1.20
- Destination IP (machine_b): 192.168.1.30
- Gateway machine has Netcat installed.
Configuring the jump
The first thing to do is make sure you are able to SSH from the Originating IP to the Jump IP and then from the Jump IP to the Destination IP. Once you are certain of this, configure the jump. This will be done on the Originating IP. Log into that machine, open a terminal window and issue the command:
sudo vim ~/.ssh/config
In that newly created file, paste the following:
ProxyCommand ssh -q -W %h:%p machine_a
Where USERNAME is a user on machine_a and machine_b (They don’t have to be the same user.). You will also want to change the IP addresses to match your needs.
The options in the above config file are:
- q – Quiet mode (supresses all warning and diagnostic messages).
- W – Requests that standard input and output on the client be forwarded to HOST on PORT over the secure channel.
- %h – Host to connect to.
- %p – Port to connect to on the remote host.
Save and close that file.
Making the connection
To jump from your Originating IP to Destination IP (through the Jump IP), you simply issue the command:
You will first be prompted for the user password on machine_a and then for the password on machine_b. Once you successfully authenticate both, you’ll find yourself on the machine_b bash prompt, having made the hop through the jump host.