SSH Chaining

Published
Length
3 min read

Luis Felipe Dias

All posts

SSH chaining routes your shell connection through one or more jump hosts to reach a private server. You set up ssh chaining by linking each hop in your local client settings. Many teams use a bastion to keep internal nodes off the public internet. Still, broad network permissions and shared keys across hops create major security risks. If one host in the chain falls, attackers can move through the network. How ssh chaining works with jump hosts and keys In a standard multi-hop setup, your wor

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

SSH chaining routes your shell connection through one or more jump hosts to reach a private server. You set up ssh chaining by linking each hop in your local client settings. Many teams use a bastion to keep internal nodes off the public internet. Still, broad network permissions and shared keys across hops create major security risks. If one host in the chain falls, attackers can move through the network.

How ssh chaining works with jump hosts and keys

In a standard multi-hop setup, your workstation cannot reach the target server directly. Instead, you first log in to a public bastion host. From that first hop, the client opens a tunnel to the next machine. You can chain several jump hosts together across isolated network zones.

Avoid storing private keys on any jump host in the chain. Instead, keep keys on your local laptop and forward challenges back to your agent. Even better, teams can replace raw static keys with OpenSSH certificates. An OpenSSH certificate holds a public key, identity info, principal names, and signed options. A central authority key signs these files using a simple format. You can set a short time window so the certificate expires on its own. Each hop checks the authority signature before it lets the connection pass through.

What native multi-hop setups solve and what they miss

Native jump host chains solve the basic network routing problem well. They let admins hide private servers behind a single hardened entry point. When combined with OpenSSH certificates, you also avoid copying public keys to every machine. The setup verifies who can open a tunnel through each hop.

Still, native chaining only controls the initial login and the network pipe. Once the tunnel connects to the final server, the chain goes blind. The jump hosts only see encrypted traffic passing through the TCP tunnel. They cannot read the shell commands an engineer runs on the destination machine. Also, forwarding a local key agent down a chain brings real danger. A rogue admin on an intermediate hop can hijack the forwarded agent socket. They can use your credentials to log in to other servers while you stay connected.

Native chains also lack fine controls over what happens inside the active session. You must grant full shell access or lock the certificate to one fixed command. You cannot pause a risky command for peer review mid-session. You also cannot rewrite sensitive output like emails, phone numbers, or card numbers. Managing host firewall rules across three or four hops takes constant manual work. When a team grows, tracking which user ran which command across hops becomes very hard.

SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Ways to reduce risk across chained hops

If you rely on native multi-hop routing, never log in to one jump host and run a second client command inside it. That habit exposes your session and tempts users to put private keys on the bastion. Instead, make the client tunnel end-to-end traffic through the intermediate hosts. Each hop should only forward encrypted bytes from your workstation to the next node.

You should also disable agent forwarding whenever you use jump hosts. When your local client drives the tunnel, it can sign each hop directly from your machine. The remote servers never get a socket to your key agent. Finally, issue short-lived user certificates with clear principal names for every engineer. This habit stops old keys from lingering on back-end servers after someone leaves the team.

Inspect one-shot SSH commands and file tasks

SSH certificates and host rules decide who is allowed on a machine. Setup alone does not check single commands or block sftp reads on sensitive paths. By design, hoop.dev runs an open-source SSH listener on the host where people and agents keep their normal ssh, sftp, and scp tools.

First, hoop.dev guardrails check one-shot commands and file paths before they run. Next, hoop.dev data masking masks matched values in file downloads. The audit trail logs the certificate principal, requested action, and verdict without storing session content. Interactive shells carry no guardrails and can be turned off when every action must be checked. Explore the code on GitHub.

Frequently asked questions

What is the difference between port forwarding and agent forwarding in a chain?

Port forwarding routes encrypted network traffic through a jump host to the next server. Agent forwarding exposes your local key signing socket to the remote machine, which carries higher risk.

Should I store my private SSH key on the bastion host?

No, you should never copy private keys onto any intermediate jump host. Keep private keys on your local machine and tunnel through the hops from there.

Do OpenSSH certificates work across multiple chained hops?

Yes, every server in the chain can trust the same central authority key. Your client presents the signed certificate at each hop to log in safely.

The query runs. The emails stay hidden.