Jump hosts (ProxyJump)
How a bastion or jump host works, why it is safe, and the syntax for one or several hops.
A jump host (or bastion) is a machine you can reach from outside that can reach machines you cannot. You connect to the jump host first, and from there to the target.
What really happens
With ProxyJump the client connects to the jump host. It then asks the jump host to open a TCP channel to the target, and runs a second SSH connection through it. So:
- The target sees your SSH client end to end. The jump host only forwards encrypted bytes.
- The jump host cannot read what you do on the target.
- The client checks the host key of both machines, and authenticates to both. Both can use different keys; see Use a different SSH key for the jump host and the target. If that check fails, see Host key verification failed through a jump host (ProxyJump).
Command line
ssh -J jump.example.com target.internal
ssh -J user1@jump1,user2@jump2 target
The config file form:
Host target
HostName 10.0.5.20
ProxyJump [email protected]
Compared with other approaches
- Agent forwarding puts your agent on the jump host. A jump host does not need it. See The agent and agent forwarding.
- ProxyCommand (
ssh -W host:port jump) is the older way.ProxyJumpis the same idea, shorter. - A shell on the jump host and then
ssh targetworks but exposes more.
Not everything works through it
- Mosh uses UDP to the target directly, so it cannot go through a jump host. Use SSH instead. See Mosh requirements. For the options, see Can Mosh go through a jump host or bastion?.
- A jump host must allow TCP forwarding (
AllowTcpForwardingin itssshd_config). If it forbids it the target connection fails.
Related
- Port forwarding
- Config file
- SSH "Connection closed by UNKNOWN port 65535": the ProxyJump or ProxyCommand failed
- App guide: Jump hosts
- Can Mosh go through a jump host or bastion?
- Host key verification failed through a jump host (ProxyJump)
- ssh-copy-id through a jump host (ProxyJump)
- SSH port forwarding through a jump host: -J with -L
- Use a different SSH key for the jump host and the target