In practice, it is often impossible to establish a direct SSH connection with a remote server because of different network segmentation policies, firewall limitations, or extremely strict security measures at the organisation’s end. This is where Jump Hosts, commonly referred to as bastion hosts, fill the gap by providing means to connect two or more network segments. Together with SSH’s ProxyJump feature, they offer a secure way to connect to servers that otherwise cannot be reached. This guide dives into SSH ProxyJump and Jump Hosts, providing practical tips and configurations to maximise their effectiveness.
If you have a server jump_host
where you can SSH directly, and another server target_host
where you can SSH from jump_host
, then you can directly access target_host
using the command:
ssh -J username@jump_host username@target_host
Replace jump_host
and target_host
with their IP addresses or domain names. Also set the username
appropriately.
SSH, or Secure Shell, is a protocol designed to secure data transmission over unsecured networks. It enables remote login, command execution, and secure file transfers (via SFTP and SCP) through encrypted communication, ensuring data protection against interception and unauthorized access.
SSH is crucial for securely replacing outdated, insecure protocols like Telnet, ensuring privacy and compliance with security standards—especially essential for organizations managing sensitive data.
A Jump Host is an agnostic intermediate system in which network traffic is switched to access the target servers from a different security domain or logical network layer. This is a controlled gateway through which the external networks can access some servers that are otherwise not directly recognisable from the external network by other users, such as the administrators and other accredited users.
In the past, Previously, when using a Jump Host, it was necessary to first establish an SSH connection to the Jump Host and then initiate another SSH connection to the target server. This process was often tedious and inefficient, causing frustration for many users. Prior to the introduction of ProxyJump, there was no simple way to specify one or more Jump Hosts in the SSH connection process, requiring complex configurations such as local port forwarding. However, with the release of OpenSSH 7.3, the ProxyJump option was introduced, allowing users to easily specify Jump Hosts directly in the SSH command or configuration file, streamlining the connection process. Learn more about ProxyJump in the OpenSSH release notes for version 7.3 .
Basic Syntax:
ssh -J [user@]jump_host[:port] target_host
To access server.destination.com
through jump.example.com
, use the following command:
ssh -J user@jump.example.com user@server.destination.com
This command tells SSH to first connect to jump.example.com as user and then connect to server.destination.com as user.
In complex environments, you may need to hop through multiple Jump Hosts to reach your target server. For example:
ssh -J user@jump1.example.com,user@jump2.example.com user@server.destination.com
This command chains two Jump Hosts, jump1.example.com and jump2.example.com, before accessing the target server.
Typing these command’s every time can prove quite cumbersome, it is therefore for convenience that you can set up your SSH client by making entries in the ~/.ssh/config file.
Host jump-host
HostName jump.example.com
User user
Host host_destination
HostName server.destination.com
User user
ProxyJump jump-host
With this configuration, you can connect to the destination server using:
ssh host_destination
As mentioned earlier when connecting through the Jump Host you can use SSH port forwarding if you try to connect directly to the port number of the target server you will not be granted access due to the TCP port forwarding.
ssh -J user@jump.example.com -L 8080:remote_service:80: user: destination_server.hostname
This command forwards your local port 8080 to remote_service:80 on server.destination.com, allowing access to the remote service through localhost:8080 on your machine.
Among the benefits of the SSH, there is a possibility to use the key-based authentication. By utilizing ssh keys, you have the ability to log into your servers without entering a password every time, which not only enhances convenience but also security.
To generate an SSH key pair, use the following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
As the next steps, hit enter to save the key pair under the default paths (~/.ssh/id_rsa and ~/.ssh/id_rsa.pub) then set a passphrase if needed. Refer to the OpenSSH key generation documentation for more details.
Use the ssh-copy-id command to copy your public key to the remote server:
ssh-copy-id user@server.destination.com
This adds your public key to the ~/.ssh/authorized_keys file on the server and allowing you to authenticate without a password.
When connecting through a Jump Host, ensure that your SSH keys are set up on both the Jump Host and the target server.
Copy your key to the Jump Host:
ssh-copy-id user@jump.example.com
Then, from the Jump Host, copy your key to the target server:
ssh user@jump.example.com
ssh-copy-id user@server.destination.com
Alternatively, you can copy your public key directly to the target server using:
ssh -J user@jump.example.com user@server.destination .com 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub
If you cannot copy your SSH key to the target server, you can use SSH agent forwarding. This allows you to authenticate to the target server using your local SSH keys.
Add the following to your SSH configuration:
Host *
ForwardAgent yes
Note that SSH agent forwarding should be used with caution, as it can be a security risk if the Jump Host is compromised.
Although ProxyJump simplifies the process of connecting through a Jump Host, there are scenarios where using ProxyCommand is preferable, especially in environments that require custom proxy settings or non-SSH proxies.
You can set up ProxyCommand in your ~/.ssh/config file:
Host host_destination
HostName server.destination.com
User user
ProxyCommand ssh -W %h:%p user@jump.example.com
This configuration instructs SSH to connect another SSH session at jump.example.com and then channel on to the target server.
While, the usage of Jump Hosts and ProxyJump make it easier to work, one needs to make sure that the network and systems are secure enough.
Large organizations are usually characterized by a highly complex topology and numerous security perimeters. These zones are tenanted by Jump Hosts which administrators use to access servers safely in the zones, preventing risking the highly sensitive items to the networks which may be relatively insecure.
Originally in cloud environment like AWS, Azure or Google Cloud, to gain access to instances located in the private subnets, the usage of the bastion hosts or Jump Hosts was well-marked. They offer a gateway to the instant without exposing all the instances to the internet.
Through a Jump Host, external vendors or support teams can be given right of entry so that essential maintenance jobs can be done without direct contact with inner resources. Such access can be well regulated and supervised.
Some standards like PCI DSS, HIPAA, and the GDPR necessitate the use of secure access and logging; Jump Hosts meet these needs in industries comprising finance, pharmaceutical, and tech.
SSH Config File Syntax: If you have not had much involvement with using SSH, then check your ~/.ssh/config file for any syntax errors or other issues. ProxyCommand Conflicts: The need to note is that if you are using both ProxyJump and ProxyCommand options, the latter is ignored. Delete configuration concerning the opponent’s moves that are currently in contrast to the current game situation.
Although ProxyJump makes Proxy configuration easier, ProxyCommand is more flexible to use to resolve non-SSH proxies which various behaviors may be needed.
Example Using ProxyCommand:
Host host_destination
HostName server.destination.com
User user
ProxyCommand ssh -W %h:%p user@jump.example.com
Connection multiplexing in the SSH converts several SSH sessions into one particular network connection hence saving a lot of overheads and enhancing the performance.
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 10m
For large scale server environments and each Linux server with unique and intricate access pattern, recommend using tools like Ansible or Puppet to automate the SSH or key management configuration.
When copying files use tools like scp or rsync with switches like -J for transfer through the jump host securely.
scp -J user@jump.example.com file.txt user@server.destination.com:/path/to/destination/
SSH ProxyJump and Jump Hosts are one of the most valuable addons in managing a complex and secure network. Through these features, administrators are put in a position to be able to control easy access to remote servers in large network topologies as well as improve the security and efficiency of the running operations. Besides, such tools define the ways of enhancing the accessibility while strengthening the given organization’s network infrastructure against various cyber threats.