A private server may accept SSH only from a bastion host, while your workstation can reach the bastion but not the server itself. OpenSSH’s -J option (also called ProxyJump) lets your local SSH client connect through that intermediate host without copying your private key onto it.
ssh -J ops@bastion.example.com deploy@10.0.4.15
Your workstation connects to the bastion, which opens a TCP connection to the private server. SSH then establishes a separate, end-to-end session with that server. You authenticate to both hosts, and your local client checks both host keys.
Start with the network path
ProxyJump does not make an unreachable network reachable by itself. Check that:
- Your workstation can reach the bastion’s SSH listener.
- The bastion can reach the destination’s SSH port.
- The bastion’s SSH server permits TCP forwarding for the connection.
The workstation does not need a direct route to the private destination. For the usual ProxyJump forwarding path, the final jump host resolves the destination hostname. This can help when a private DNS name is known inside the network but not on your laptop.
If you have authorized access to the bastion, test its route to the destination separately:
nc -vz 10.0.4.15 22
For a quick overview of how SSH port forwarding works, including local and remote tunnels, see this guide to SSH tunneling.
Configure each hop separately
A one-off command is useful for testing. For regular access, put each host’s settings in ~/.ssh/config:
Host bastion
HostName bastion.example.com
User ops
Port 2222
IdentityFile ~/.ssh/bastion_key
IdentitiesOnly yes
ForwardAgent no
Host db-server
HostName 10.0.4.15
User deploy
IdentityFile ~/.ssh/db_key
IdentitiesOnly yes
ProxyJump bastion
Now connect with the destination alias:
ssh db-server
Separate host blocks make it clear which user, port, and key apply at each hop. This matters if the bastion and destination use different accounts or keys. A destination -i option should not be assumed to configure the separate SSH process used for the jump host.
To see the settings OpenSSH will actually use, inspect the effective configuration:
ssh -G db-server | grep -E '^(hostname|user|port|proxyjump|identityfile|identitiesonly) '
If SSH offers unexpected keys, check for overlapping Host blocks or included configuration files: identity settings can accumulate. IdentitiesOnly yes limits agent key offers to configured identities, but checking ssh -G is still useful.
Understand what the bastion can—and cannot—see
ProxyJump does not copy your destination private key to the bastion, and it does not require agent forwarding. Your local SSH client authenticates to the destination through the forwarded TCP connection. Leaving agent forwarding disabled avoids making your local agent available to processes on the bastion.
The bastion is still part of the trust and network path. It can see the destination address and connection metadata, even though it cannot decrypt a correctly verified destination SSH session. Verify host keys for both hosts; do not work around a host-key warning by disabling checking.
Diagnose errors by hop
Run verbose SSH output when a connection fails:
ssh -vvv db-server
Look for which hostname is being contacted or authenticated when the error occurs. A Permission denied (publickey) message could come from either host; confirm the username and key for the failing hop. If public-key authentication is the problem, this publickey troubleshooting guide walks through common causes.
An error like channel ... open failed: administratively prohibited points to a forwarding-policy restriction on the bastion, rather than necessarily indicating a bad password or key. An administrator can inspect effective SSH server settings and any forwarding restrictions, such as AllowTcpForwarding, DisableForwarding, or PermitOpen. Avoid changing production policy without understanding the security impact.
A timeout can occur on either leg: workstation to bastion, or bastion to destination. Test those paths separately. For a hostname error, identify which machine is resolving the name; the destination name may be available only from the jump host.
Use the route for file transfers
Modern OpenSSH scp and sftp can also use a jump host. Specify the destination as the transfer endpoint:
scp -J ops@bastion.example.com ./report.txt deploy@10.0.4.15:/tmp/report.txt
sftp -J ops@bastion.example.com deploy@10.0.4.15
If you have configured ProxyJump on a destination alias, you can reuse it:
scp ./report.txt db-server:/tmp/report.txt
A jump host is a route, not a substitute for network controls or least-privilege access. Keep the destination restricted to intended networks, use appropriate accounts and keys, and review forwarding rules deliberately.
I originally published a more detailed version of this guide on the ShadeTerm blog.
I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.
Top comments (0)