Skip to content

SSH agent forwarding

With agent forwarding, an SSH session can sign in from the remote server to a further server with your keys, without your private keys ever being copied to the remote host. ZestSSH answers the remote host’s agent requests itself, with an agent built into the app.

Platform Status
Android Full support
iOS Full support
Windows Full support
macOS Full support
Linux Full support
  1. Open the host in the host editor.
  2. Turn on Forward SSH agent:
    • On a computer: the Auth tab, under Options.
    • On a phone: tap Advanced options, then find it under Options.
  3. Make sure the host signs in with an SSH key (not a password only), picked in its Key field.
  4. Save the host and connect.
  5. On the remote server, ssh to the next server. The remote ssh uses your forwarded key.

ZestSSH’s agent lives inside the app and holds the key the session signed in with. It is not a separate program like the system’s ssh-agent.

  1. Setting up. When a host has Forward SSH agent on and the session signed in with a key, ZestSSH makes an agent holding that key.
  2. Asking the server. ZestSSH asks the server for agent forwarding (auth-agent-req@openssh.com).
  3. Listing keys. When a program on the remote host (such as ssh) needs to sign in somewhere, it asks the agent which keys it has, and ZestSSH answers with the session’s key.
  4. Signing. When that program picks the key, it sends what to sign. ZestSSH signs it and returns the signature.
  5. Signing in onward. The remote program signs in to the next server with that signature, and never sees the private key.

The agent holds the key picked in the host’s Key field:

  • A software key saved in ZestSSH signs inside the app.
  • A key with a certificate is forwarded with its certificate and signs with the key inside it.
  • A key held by an SSH agent (the system’s, 1Password’s or Bitwarden’s) is passed through: each sign request goes to that agent, and a hardware key asks for its touch as usual. Other keys in that agent are never forwarded.

Agent forwarding is set for each host, so you can turn it on only where you need it (for example a bastion) and leave it off elsewhere. The switch is saved with the host and syncs with it.

  • RSA: SHA-512 or SHA-256 when the request asks for one; the old SHA-1 kind only when the request names neither. Each RSA signature is checked against the key’s public half before it is handed out.
  • Ed25519, Ed448 and ECDSA (P-256, P-384, P-521): their standard signatures.

Agent forwarding is powerful, but it has a cost. Know it before you turn it on.

With agent forwarding on, the remote server can use your key to sign in as you elsewhere while your session is open. A compromised remote server could:

  • Use your forwarded key on any server that trusts it.
  • Open connections as you, quietly, while your session is connected.

Turn on agent forwarding only for servers you fully trust. Never turn it on for shared or multi-tenant hosts.

A forwarded agent signs with no question asked: while you are connected, anyone with root on that host can use your keys. ZestSSH tells you when a host has a key sign through it, at most once a minute for each host, as a git pull signs several times: “web-01 used your SSH key through the forwarded agent”. The same goes in that session’s connection log. It tells you after the fact, and it is the only trace there is.

The remote server can ask for signatures but never receives the private key. Signing happens on your device (or in your SSH agent).

The forwarded agent works only while the session is connected. Once you disconnect, its channel closes and no more signing requests can be made.

Server Monitor’s own background connections never forward your agent, whatever the host’s switch says.

Before a backup is restored, ZestSSH lists the hosts in it that would act by themselves, including those that forward your agent, so you can check them before anything is written.

To reach a second server, consider these safer ways first:

  • Jump hosts (ProxyJump): ZestSSH connects through a jump host to the next server without forwarding your agent. See Jump host.
  • A separate key: put a separate key on the remote server for onward connections, so a compromise there reaches less.
  • The session’s key only. Forwarding offers the key the session signed in with, not every key in ZestSSH and not every key in your system’s agent.
  • No keys added later. The agent holds what the session signed in with; you cannot add keys after connecting.
  • Keys only. A host that signs in with a password has no key to forward, and forwarding is skipped.
  • SSH sessions only. Mosh, Eternal Terminal, Telnet and serial sessions do not forward the agent.

Forwarding is separate from your computer’s SSH agent. On a computer, Add to agent on the Keys page gives a key of your vault to this computer’s SSH agent (for an hour, 8 hours, or until you sign out; on Windows, until you remove it), so that ssh, git and other tools on the computer can sign in with it. The key’s details then say SSH agent: Loaded, and the In agent filter lists it. Phones have no system agent. See Add a key to the SSH agent.

  • Check that Forward SSH agent is on for the host.
  • Check that the host signs in with a key, not a password.
  • Check that the server allows it: AllowAgentForwarding yes in sshd_config.
  • The connection’s log says ssh_agent: Agent forwarding enabled when it is on, or ssh_agent: Agent forwarding skipped (no keys) when there is no key to forward.

ZestSSH shows the notice “host refused agent forwarding”: “The session goes on without it, so your keys cannot be used from that host. Its server allows no agent forwarding, or the key that signed in is marked so.” The session stays open. Check AllowAgentForwarding in the server’s sshd_config, and any no-agent-forwarding option on the key’s line in authorized_keys.

The remote ssh asks for a password despite the agent

Section titled “The remote ssh asks for a password despite the agent”
  • Check that the next server trusts the public key of the host’s key in ZestSSH.
  • On the remote server, run ssh-add -l. It should list your key.
  • If ssh-add -l says “Could not open a connection to your authentication agent”, the server is not setting up the agent socket for your session.

Q: Is agent forwarding the same as ProxyJump? A: No. ProxyJump tunnels the connection through a middle host without giving it your keys. Agent forwarding lets the remote host use your key for onward sign-ins, so you must trust that host. ProxyJump is generally safer.

Q: Can I forward my system ssh-agent’s keys through ZestSSH? A: If the host signs in with a key from your system’s agent (added on the Keys page with Connect via ssh-agent), that key is forwarded, and its sign requests go to your agent. Other keys in your agent are not forwarded. See FIDO2 hardware keys.

Q: Does agent forwarding work with Mosh? A: No. Use an SSH session for connections that need agent forwarding.