A bastion (or “jump host”) is the single entry point through which operators reach private hosts. Done well, it is the place where access is logged, MFA is enforced, and the private network stays private. Done poorly, it becomes the host where everyone forwards their agent and where one compromise unlocks the fleet. ProxyJump is the OpenSSH feature that makes the well-done version easy. This article walks the full setup.
How to verify
Check whether your client supports ProxyJump and whether the bastion is reachable.
ssh -V
# expect OpenSSH_7.3 or newer (released 2016-08, ubiquitous now)
nc -zv bastion.example.net 22
ssh -G bastion | grep -iE 'hostname|user|port|identityfile'
ssh -J ops@bastion.example.net -o ConnectTimeout=5 ops@10.0.5.10 'hostname'
The last command tunnels through bastion to reach 10.0.5.10. If it returns the inner hostname, ProxyJump works end-to-end.
What’s happening
Before ProxyJump, reaching an internal host through a bastion meant either nesting ssh calls (ssh bastion ssh internal) — which puts the inner shell on the bastion and is awful for scp/sftp/forwards — or using ProxyCommand ssh bastion nc %h %p — which works but requires netcat on the bastion and is finicky.
ProxyJump (introduced in OpenSSH 7.3) is the clean version. The client opens a TCP connection to the bastion’s sshd, asks it to open a TCP connection to the target host, and then runs the entire SSH handshake — key auth, channel setup, the whole protocol — end-to-end between your workstation and the target. The bastion is a TCP forwarder; it never sees your authentication or your agent.
The target host’s sshd authenticates the connection as if it came directly from you. The bastion’s sshd authenticates the jump. Two separate authentications, two separate audit trails. This is the model that makes bastions actually defensible.
The procedure
-
Configure the bastion in
~/.ssh/config. StandardHostblock.Host bastion HostName bastion.example.net User ops IdentityFile ~/.ssh/id_ed25519_ops ControlMaster auto ControlPath ~/.ssh/sockets/%C ControlPersist 10mControlMasterhere makes multiple ProxyJump sessions reuse a single bastion connection — important for performance when running an Ansible playbook through the bastion. -
Configure target hosts with
ProxyJump. Either per-host or with a glob.Host db-* app-* worker-* ProxyJump bastion User ops IdentityFile ~/.ssh/id_ed25519_opsWith this in place,
ssh db-01connects todb-01via the bastion automatically.scp file.txt db-01:/tmp/works.rsync -av src/ db-01:/srv/works. Anything that uses SSH inherits the jump. -
Test from a fresh shell.
ssh db-01 'hostname; ip -4 -o addr show eth0 | awk "{print \$4}"'Should return the internal hostname and the internal IP — proof the connection terminated on the target, not the bastion.
-
For ad-hoc one-off jumps, the
-Jflag is equivalent.ssh -J ops@bastion.example.net ops@10.0.5.10 scp -J ops@bastion.example.net file.txt ops@10.0.5.10:/tmp/Multiple jumps are comma-separated:
-J host1,host2. The connection tunnels through both. -
Lock down the bastion’s sshd. The bastion’s job is to forward, log, and authenticate the jump. It should not run application services, should not allow agent forwarding, and should rate-limit attempts.
# /etc/ssh/sshd_config.d/01-bastion.conf AllowAgentForwarding no X11Forwarding no PermitTunnel no AllowTcpForwarding yes # required for ProxyJump PermitOpen any # or restrict to known target subnets ClientAliveInterval 60 ClientAliveCountMax 3AllowTcpForwarding yesis required — that is what ProxyJump does under the hood.AllowAgentForwarding noprevents the legacy pattern. -
Restrict who can use the bastion as a jump.
PermitOpencontrols which destination host:port pairs the bastion will forward to.PermitOpen 10.0.5.0/24:22 10.0.6.0/24:22The bastion will refuse to open TCP connections to anything not in those subnets/ports. A user who somehow gets a shell on the bastion still cannot pivot to public networks through it.
-
Centralize the bastion’s logs. Every successful jump and every failed attempt should be visible to the security team.
sudo journalctl -u ssh -g 'Accepted publickey for' --since "1 hour ago" sudo journalctl -u ssh -g 'Failed publickey for' --since "1 hour ago"Pipe these into your central log store (Loki, ELK, OpenSearch) with
rsyslogorvector. -
For multi-hop, chain them.
Host inner-target HostName 10.20.30.40 ProxyJump bastion-outer,bastion-inner User opsThe client tunnels TCP through
bastion-outer, then throughbastion-inner, then authenticates against the target. Each bastion is a TCP forwarder; only the final SSH handshake authenticates againstinner-target.
Common pitfalls
- Setting
AllowTcpForwarding noon the bastion — disables ProxyJump entirely, often without a clear error message on the client. - Using
ProxyJumpandProxyCommandin the same Host block; ProxyJump takes precedence and ProxyCommand is silently ignored. - Forgetting that the target host’s
authorized_keysmust contain your key, not the bastion’s. ProxyJump authenticates end-to-end. - Multi-hop with different identities; if the bastion needs
id_ed25519_opsand the target needsid_ed25519_prod, yourHostblocks must declare the right IdentityFile for each, andIdentitiesOnly yesis essential or the agent offers all keys to the bastion. - Long-running rsync or scp through a bastion that has aggressive
ClientAliveCountMax; the TCP forward is dropped after the configured timeout. Set the bastion’s keepalive generously or use-o ServerAliveInterval=30from the client.
In the fleets we operate, every private host is reachable only through a bastion, and every bastion is configured exactly this way: ProxyJump as the primary mode, no agent forwarding, scoped TCP forwarding, centralized logs. Operators do not think about it because the ~/.ssh/config makes the bastion invisible. That layer is what Managed Operations provides as the floor for client access.