Skip to content

Host key verification

Every SSH server proves who it is with a host key, a key pair whose private half only that server holds. Checking the host key is what stops you from typing a password into an impostor that sits between you and the real server. ZestSSH checks the host key on every connection and keeps a record of the keys you trusted, so it can tell you when one changes.

Host key checks work the same on every plan, on phones and computers.

ZestSSH uses the usual SSH model, trust on first use:

  1. The first connection to a host. ZestSSH has not seen its key before, so it shows the key’s fingerprint and asks you first.
    • The question is the same on a computer and a phone. Its title names the server, for example First connection to web-01.example.com (with the port when it is not 22), and it says: “ZestSSH has not seen this server’s key before. Check it once: after that it is remembered, and you are warned if it changes.”
    • The key’s type (for example ED25519) stands over its SHA256 fingerprint, in groups of four characters so it is easy to compare. Copy fingerprint copies it whole, as SHA256: and the 43 characters with no spaces.
    • Check it on the server: gives the ssh-keygen -lf command for that key type’s usual file on the server (for example ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub), with its own copy button. You can also compare it with the fingerprint your hosting provider shows.
    • Choose Trust and connect to keep the key and go on, or Reject.
  2. Every connection after that. ZestSSH compares the key the server shows with the one it kept. When they match, the connection goes on without a question. When they differ, the connection stops (see When the key has changed).

Fingerprints are SHA-256, written the way OpenSSH writes them, for example SHA256: followed by 43 characters.

Saying no to a new key ends the connection, and nothing is kept.

The trusted keys are kept in ZestSSH’s own encrypted database (see Data at rest), not in an OpenSSH known_hosts file. For each key, ZestSSH keeps:

  • the host and port,
  • the key type, for example ssh-ed25519, ssh-rsa or ecdsa-sha2-nistp256,
  • the SHA-256 fingerprint and the whole public key,
  • when you first trusted it, and when it was last seen,
  • the name of the device that first trusted it.

A host you reach through jump hosts is trusted for that route. The same address reached directly, or through other jump hosts, has a record of its own. A host whose direct record a version before 3.3 moved to its route, when you gave it a jump host, is asked about once as a new host the next time you reach it directly.

Before it looks a host up, ZestSSH writes the address the same way each time: in lower case, without spaces around it, without a final dot (Example.com. is example.com) and without the brackets of an IPv6 address ([::1] is ::1). An RSA key named rsa-sha2-256 or rsa-sha2-512 is kept as ssh-rsa, the type of the key itself. So a server you trusted is not asked about again because it was named a little differently.

Unknown host keys: ask, or trust on first use

Section titled “Unknown host keys: ask, or trust on first use”

You choose what happens with a key ZestSSH does not know yet:

  • On a computer: Settings > Security and privacy, under Host keys, Unknown host keys: Ask before trusting (the default) or Trust on first use.
  • On a phone: More > Settings > Security and privacy, under Host key trust, the switch Ask before trusting new keys.

With trust on first use, a new key is trusted without a question, and a notice says so: “New host key auto-accepted for” the host, with its key type and fingerprint, and a Settings button.

Two things always ask, whatever you chose:

  • A changed key always stops the connection. No setting trusts a key that replaced one you trusted.
  • A host reached at another address because of a network rule is always asked about, so you see the address that was actually dialed before you trust it.

A run with nobody there to answer, such as an automation link, an Android intent or a scheduled task, never trusts a key by itself, whatever this setting says:

  • A host whose key this device does not know yet is not connected to: “This device does not know the host’s key yet, and a new key is not accepted when nobody is there to check it.” Connect to the host in the app once and accept its key.
  • A host whose key changed is not signed in to, and nothing runs.

See Automation.

Trusted host keys travel with sync and with backups. A key that arrives this way is taken only when it names the device that trusted it and a date in the past. The first time this device connects with such a key, ZestSSH tells you where it came from: the host “was trusted using a key recorded on” that device on that date, “(synced from another device)”. If you do not recognise the device, check the fingerprint.

When this device already trusts another key for the same host and key type, the key it has is kept. Neither key is trusted twice, and the next connection shows the difference as a changed key.

A key ZestSSH trusted no longer matches the key the server just showed. ZestSSH counts two cases as a change:

  • Another key of the same type.
  • Another type of key. The host is known with one type (say ssh-rsa) and now shows another (say ssh-ed25519) that it has no record of. ZestSSH treats this as a change, not as a new host.

A changed key often has a harmless cause: the server was rebuilt, its host keys were made again, or another machine now answers at that address. It is also exactly what someone in the middle of the connection looks like, so ZestSSH never decides for you.

ZestSSH stops and shows Host key changed, on phones and computers:

  • A banner names the host and says what the change most often means, and that it can also mean someone is intercepting the connection.

  • The key you trusted, under Expected, trusted and the date and time you trusted it, and the key the server showed, under Received now. A key trusted before fingerprints were kept shows “Expected, trust date unknown”.

  • “Not sure? Run this on the server itself and compare the fingerprint it prints:” and a command for the key’s type, with Copy command. For an Ed25519 key it is:

    ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub

    For a key type it does not recognise, the command prints the fingerprint of every host key on the server.

  • “Trusting the new key permanently replaces the key saved for this host.”

Cancel and disconnect has the keyboard focus, so pressing Enter takes the safe choice. Trust new key is the red button beside it, which you have to choose on purpose. Tapping or clicking outside the warning does not close it.

With Security alerts on in your notification settings, a notice “Host key changed” also goes to the notification center.

As soon as a change is seen, the host is marked. Its card shows a red shield, with “Host key changed” when you point at it, and the host’s panel says “The key changed”. The mark stays when you cancel. It goes only when you trust the new key.

The mark is kept on this device only. It does not sync.

Check the new key another way first, for example with the ssh-keygen command above, run on the server’s console. When the fingerprint it prints matches Received now, choose Trust new key. ZestSSH then replaces the key it kept for this host, clears the mark and connects.

If you are not sure, choose Cancel and disconnect and find out first.

A host that shows an RSA host key shorter than 2048 bits is not connected to (versions before 3.3.0 took 1024 bits and up). ZestSSH says how long the key is and that the host needs a longer one. For an old device that cannot make one, turn on Compatibility mode for that host: it takes such a key.

  • On a computer: Settings > Security and privacy, under Host keys: Trusted host keys with Manage, and Clear all trusted keys with Clear all.
  • On a phone: More > Settings > Security and privacy, under Host key trust: Trusted host keys and Clear all trusted keys.

Trusted host keys lists each key with its host, key type, fingerprint and when it was last seen. Remove host key removes one, after “Remove host key?”: the next connection to that host asks again. Clear all trusted keys removes every key, after “Clear all trusted keys?”.

In a team, someone who may edit a vault can trust a host’s key for everyone in it. Other members then connect to that host without a question, and another key stops them. See Team host keys.

  • Trusting a changed key out of habit. Read both fingerprints. The warning puts the focus on Cancel and disconnect so that a quick Enter does not trust the new key.
  • Checking against the same connection. A fingerprint shown over the connection you doubt proves nothing. Use another way in: the server’s console, your provider’s dashboard, or the person who runs the server.
  • Removing a trusted key to make a warning go away. That only makes the next connection a first connection again, and hides the change. Check the key, then trust it.