Skip to content

Setting up jump hosts

A jump host (bastion host) is a single server exposed to the internet that acts as a gateway to your private network. Instead of exposing every server to the public internet, you expose one hardened machine and tunnel through it to reach everything else.

ZestSSH has jump hosts built in through the Connect via (optional) field of a host, so you do not need an SSH config file or command-line syntax.

Note: Connect via needs ZestSSH Squeezed. On the free plan the field shows a lock with Upgrade, and a host that already has Connect via set (from sync or an import) is connected to directly instead, with the notice “Connect Via needs Squeezed. Connecting directly instead.”

When you set host B’s Connect via (optional) to host A, ZestSSH:

  1. Signs in to host A (the jump host).
  2. Opens a channel through host A to host B’s address and port.
  3. Runs a separate SSH connection to host B inside that channel, with host B’s own host key check and sign-in.

The SSH connection to the destination is encrypted from your device to the destination. The jump host only passes it along and cannot read your session with the destination.

Add a host for your bastion (New host on a computer’s Hosts page, + on a phone’s Hosts tab):

  • Nickname: Bastion
  • Address: your public address or DNS name (for example bastion.example.com), with its port (22, or the one you moved it to) in the port box
  • Key: an SSH key just for this jump host

Your bastion is the single point of entry. Secure it:

  • Turn off password sign-in (PasswordAuthentication no in sshd_config)
  • Use SSH key sign-in only
  • Install fail2ban or a similar rate limiter
  • Restrict which users can sign in (AllowUsers jumpuser)
  • Turn off agent forwarding on the bastion unless you need it
  • Run SSH on a non-standard port to reduce noise
  • Keep the OS and OpenSSH patched

For each server behind the jump host, add a host:

  • Nickname: DB Primary
  • Address: 192.168.20.5 (a private address, not reachable from the internet), port 22
  • Key: a key for this server (the same as the bastion’s or another one)
  • Connect via (optional): choose Bastion. On a computer it is in the editor’s Network section; on a phone, tap Advanced options first.

When you connect to DB Primary, ZestSSH connects to the bastion first, then goes through it to 192.168.20.5:22. The address is reached from the bastion, so it is the bastion’s network that has to reach 192.168.20.5, not yours.

A host’s key is remembered under the jump host it is reached through. Two different servers that share the address 192.168.20.5 behind two different bastions each keep their own key, and neither shows up as a changed key for the other.

Step 3: Port forwarding through a jump host

Section titled “Step 3: Port forwarding through a jump host”

Say your database server runs PostgreSQL on port 5432. You can reach it from your device in two ways.

A forward on the destination host. The forward runs on DB Primary’s own connection, which goes through the bastion. On a computer:

  1. Open Port forwarding in the side rail and click New rule.
  2. Under What do you want to do?, choose Reach a service on the server.
  3. Server: DB Primary. Port here: 5432. Port on server: 5432.
  4. Click Save and start (or Save, then Start). If DB Primary has no open session, ZestSSH asks to connect first.

In this simple form the service is reached on the server itself (localhost there), which is what you want here.

A forward on the bastion. The bastion opens the connection to the database, so it works for any address the bastion can reach. On a computer, use New rule, switch to Advanced, choose Host Bastion, Type Local (-L), Source port 5432, and Destination host 192.168.20.5, port 5432. On a phone, go to More, then Port forwarding, tap +, choose Bastion, then fill in Source port 5432, Destination host 192.168.20.5 and Destination port 5432, and tap Add.

Either way, your device can then reach the database at localhost:5432.

ZestSSH follows chains of jump hosts. This is useful where a network has several security zones:

Internet --> Bastion (public) --> DMZ Server --> Internal Server

Set up:

  1. Bastion: no Connect via.
  2. DMZ Server: Connect via = Bastion
  3. Internal Server: Connect via = DMZ Server

When you connect to the Internal Server, ZestSSH connects to the Bastion, goes through it to the DMZ Server, and then through that to the Internal Server. Each hop is its own encrypted SSH connection with its own host key check.

A network can also set a different jump route for a host while your device is on that network, or none at all.

ZestSSH checks the chain before it connects:

  • A jump host that was deleted: “The jump host that DB Primary is set to connect through is no longer there. Open DB Primary and pick another under Connect via, or Direct.”
  • Jump hosts that lead back to one already on the way: “The jump hosts of Internal Server go in a circle: DMZ Server comes up a second time on the way. Change Connect Via of one of them.”

Each hop adds its own SSH handshake and sign-in before the next one starts, so a chain takes longer to open than a direct connection. Keep chains as short as your network allows.

Use a different SSH key for the bastion and for each destination server:

  • Bastion: bastion-key (Ed25519)
  • DB Primary: db-key (Ed25519)

ZestSSH signs in to each hop with the key of that hop’s own host, from your device. The bastion never sees the key you use for the destination server, and you do not need agent forwarding for Connect via.

Forward SSH agent (on a computer, the editor’s Auth tab; on a phone, under Advanced options) is for a session you work in. It lets the server use the keys of that session to sign in onward when you run ssh from its shell. It is never used on the jump hosts of a Connect via chain.

Agent forwarding has a security trade-off: anyone with root access on that server can use your forwarded keys while the session is open. Use it only on servers you fully trust. If the server refuses agent forwarding, the session still opens without it.

Startup commands work normally through jump hosts. If you set Startup command (optional) to tmux new-session -A -s main on a host behind a jump host, it runs on that host, not on the jump host. The startup command goes to the shell of the server you finally connect to.

ZestSSH’s automation (links, Tasker and Shortcuts) works with hosts behind jump hosts. A link like this one (with your own API key):

zestssh://execute?connection=DB%20Primary&command=uptime&key=YOUR_API_KEY

asks first: “Run this from a link?” names the host and the command, and nothing runs until you tap Run. ZestSSH then goes through the bastion to DB Primary, runs the command and returns the result. The caller does not need to know about the jump host. The connection value is the host’s nickname (any capitalization) or its ID.

A run with nobody there to answer (from another app or a schedule) signs in only with keys that have Allow unattended runs turned on in Keys, and that goes for every key it would use: the destination’s and each jump host’s. Otherwise it stops with a message such as “bastion-key is not allowed for unattended runs. Allow it in Keys, or open this host yourself.” It also accepts no host key this device does not already trust, so connect to each hop once by hand first. Automation needs Squeezed. See Automation.

When a hop fails, ZestSSH names the jump host and the step that failed, for example:

  • “The jump host Bastion could not be reached.” The bastion itself did not answer: check its address, port and your network.
  • “Signing in to the jump host Bastion did not work.” Check the bastion’s key.
  • “The jump host Bastion does not pass connections on to DB Primary: forwarding is turned off there, or not allowed for this account or key.” On the bastion, check AllowTcpForwarding in sshd_config and any restrict or no-port-forwarding options on your key in authorized_keys.
  • “The jump host Bastion could not reach DB Primary itself.” The bastion was fine, but it could not open a connection to the destination. Check the destination address and port as the bastion sees them, that the destination’s SSH server is running, and that its firewall lets the bastion in. To test, sign in to the bastion and run ssh 192.168.20.5.

Host key checks on the destination: ZestSSH checks the host key of each hop on its own. If the destination’s key has changed, you see Host key changed with Trust new key and Cancel and disconnect. Look into it before you trust the new key: a changed host key can mean someone is in the way.

Drops: if the connection to a jump host ends, the session behind it ends too, and ZestSSH says so: “The connection to DB Primary goes through the jump host Bastion, and it was the connection to that jump host that ended.”

For more, see Jump host and Connection issues.