Skip to content

SSH ProxyJump — bastion access without exposing your agent

ProxyJump replaces nested ssh calls and the older ProxyCommand pattern with a clean, end-to-end-authenticated tunnel through one or more bastions. Here is the full setup.

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

  1. Configure the bastion in ~/.ssh/config. Standard Host block.

    Host bastion
        HostName bastion.example.net
        User ops
        IdentityFile ~/.ssh/id_ed25519_ops
        ControlMaster auto
        ControlPath ~/.ssh/sockets/%C
        ControlPersist 10m

    ControlMaster here makes multiple ProxyJump sessions reuse a single bastion connection — important for performance when running an Ansible playbook through the bastion.

  2. Configure target hosts with ProxyJump. Either per-host or with a glob.

    Host db-* app-* worker-*
        ProxyJump bastion
        User ops
        IdentityFile ~/.ssh/id_ed25519_ops

    With this in place, ssh db-01 connects to db-01 via the bastion automatically. scp file.txt db-01:/tmp/ works. rsync -av src/ db-01:/srv/ works. Anything that uses SSH inherits the jump.

  3. 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.

  4. For ad-hoc one-off jumps, the -J flag 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.

  5. 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 3

    AllowTcpForwarding yes is required — that is what ProxyJump does under the hood. AllowAgentForwarding no prevents the legacy pattern.

  6. Restrict who can use the bastion as a jump. PermitOpen controls which destination host:port pairs the bastion will forward to.

    PermitOpen 10.0.5.0/24:22 10.0.6.0/24:22

    The 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.

  7. 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 rsyslog or vector.

  8. For multi-hop, chain them.

    Host inner-target
        HostName 10.20.30.40
        ProxyJump bastion-outer,bastion-inner
        User ops

    The client tunnels TCP through bastion-outer, then through bastion-inner, then authenticates against the target. Each bastion is a TCP forwarder; only the final SSH handshake authenticates against inner-target.

Common pitfalls

  • Setting AllowTcpForwarding no on the bastion — disables ProxyJump entirely, often without a clear error message on the client.
  • Using ProxyJump and ProxyCommand in the same Host block; ProxyJump takes precedence and ProxyCommand is silently ignored.
  • Forgetting that the target host’s authorized_keys must contain your key, not the bastion’s. ProxyJump authenticates end-to-end.
  • Multi-hop with different identities; if the bastion needs id_ed25519_ops and the target needs id_ed25519_prod, your Host blocks must declare the right IdentityFile for each, and IdentitiesOnly yes is 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=30 from 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.