1.6. Connecting to a remote server through an SSH jump host
Connect securely from your local system to a remote server by using a jump host as an intermediary. This approach manages connections between hosts located in different security zones.
Prerequisites
- A jump host accepts SSH connections from your local system.
- A remote server accepts SSH connections from the jump host.
Procedure
If you connect through a jump server or more intermediary servers once, use the
ssh -Jcommand and specify the jump servers directly, for example:$ ssh -J <jump-1.example.com>,<jump-2.example.com>,<jump-3.example.com> <target-server-1.example.com>Change the hostname-only notation in the previous command if the user names or SSH ports on the jump servers differ from the names and ports on the remote server, for example:
$ ssh -J <example.user.1>@<jump-1.example.com>:<75>,<example.user.2>@<jump-2.example.com>:<75>,<example.user.3>@<jump-3.example.com>:<75> <example.user.f>@<target-server-1.example.com>:<220>If you connect to a remote server through jump servers regularly, store the jump-server configuration in your SSH configuration file:
Define the jump host by editing the
~/.ssh/configfile on your local system, for example:Host <jump-server-1> HostName <jump-1.example.com>-
The
Hostparameter defines a name or alias for the host you can use insshcommands. The value can match the real hostname, but can also be any string. -
The
HostNameparameter sets the actual hostname or IP address of the jump host.
-
The
Add the remote server jump configuration with the
ProxyJumpdirective to~/.ssh/configfile on your local system, for example:Host <remote-server-1> HostName <target-server-1.example.com> ProxyJump <jump-server-1>Use your local system to connect to the remote server through the jump server:
$ ssh <remote-server-1>This command is equivalent to the
ssh -J jump-server1 remote-servercommand if you omit the previous configuration steps.