Skip to content

Public key authentication

Public key authentication is the recommended way to sign in to SSH servers. ZestSSH generates, imports and manages SSH keys on every platform. A key’s private half is kept in your device’s secure storage, never in the app’s database.

Platform Status
Android Full support
iOS Full support
Windows Full support
macOS Full support
Linux Full support
Key type Sizes Notes
Ed25519 Fixed The recommended choice: fast and compact
RSA 2048 or 4096 bits 4096 bits for servers that need RSA
ECDSA P-256, P-384 or P-521 For setups that require the NIST curves

ZestSSH reads these private key files:

  • OpenSSH format (-----BEGIN OPENSSH PRIVATE KEY-----), the default of ssh-keygen: Ed25519, RSA, ECDSA and Ed448, with or without a passphrase.
  • RSA PEM (-----BEGIN RSA PRIVATE KEY-----), with or without a passphrase. A passphrase-protected one opens when it was encrypted with AES (CBC or CTR).
  • EC PEM (-----BEGIN EC PRIVATE KEY-----), without a passphrase only.
  • PuTTY .ppk (versions 2 and 3): RSA and Ed25519 keys, with or without a passphrase. ZestSSH converts the key to OpenSSH format as it imports it.

Other files, such as PKCS#8 keys (-----BEGIN PRIVATE KEY-----) and DSA keys, are refused, and ZestSSH says why in your language.

  1. Open Keys in the sidebar.
  2. Choose New key, then Generate SSH key (Ed25519), Generate SSH key (ECDSA) or Generate SSH key (RSA-4096).
  3. In Generate SSH key, set the Key name, check the key type and strength, and change the Comment if you like (it starts as user@ZestSSH).
  4. Choose Generate key pair. The public key is shown, with Copy public key and Share public key.
  5. Choose Save & use this key. The key’s form opens with the new key in it: set the Username and choose Save.

If you close the generator with Done before saving, ZestSSH asks whether to save the key first.

  1. Open More, then Keys, and tap +.
  2. Fill in Display name and Username, and choose SSH key.
  3. Tap Generate new key, pick the Key format and Key strength, and tap Generate key.
  4. Tap Save key.

On a computer:

  1. Open Keys, choose New key, then Import or paste key.
  2. Fill in Display name and Username, then choose Set up SSH key.
  3. In Set up SSH key, use the Paste tab to paste the private key, or the Import tab and Choose key file.
  4. If the key has a passphrase, ZestSSH asks for it (Key passphrase, then Decrypt).
  5. Choose Save.

On a phone, open Manage > Keys, tap +, choose SSH key, then Paste key or Import from file (“Load a .pem, .ppk, or OpenSSH key file”), and tap Save key.

The public key is worked out from the private key; you never paste it separately.

Then open the host and pick the key in its Key field.

  1. ZestSSH reads the host’s key from secure storage.
  2. If the key has a passphrase, ZestSSH uses the saved one. If none is saved, it asks (SSH key passphrase), and Remember passphrase saves what you type with the key.
  3. ZestSSH first asks the server whether it takes the key. The key signs only for a server that says yes, so a key the server would refuse is passed over without signing (and an SSH agent or hardware key is not asked to sign for it).
  4. An RSA key signs with SHA-512 where the server takes it, otherwise with SHA-256. The old SHA-1 kind is used only where Compatibility mode is on for that host. Where the server takes none of these, the key is not sent and ZestSSH says so.
  5. The server checks the signature against the public key in authorized_keys.

A key can also hold a password in Password, tried after the key. ZestSSH sends it only to a server that does not take the key and asks for a password. Left empty, only the key is used.

Part Where it is kept
Private key The system’s secure storage
Passphrase (if saved) The system’s secure storage
Certificate (if any) The system’s secure storage
Public key line, name, username The app’s database

With Encrypt data at rest on (Settings > Security and privacy), the private key, passphrase and certificate are also sealed with a key that opens only after your PIN.

  • Your other devices and backups. A key goes, with its passphrase and certificate, to your other devices through sync, end-to-end encrypted, and into your encrypted backups.
  • Export. Export… (on a computer in the key’s details; on a phone, long-press the key, then Key actions) writes OpenSSH key files, with the passphrase the key has, a new one typed twice, or none, and opens the share sheet. On a phone, the key’s editor also has the loaded key’s SSH key dialog, whose copy icon on Private key copies the private key (cleared from the clipboard after 45 seconds), and the download icon, which exports it as a file. See Exporting keys.
  • The SSH agent, on a computer. Add to agent gives the key to this computer’s SSH agent for an hour, 8 hours or until you sign out, so other apps (ssh, git) can sign in with it. See Add a key to the SSH agent.
  • Mosh and Eternal Terminal. These sessions run an outside program, which gets the key as a temporary file for the session; it is removed when the session ends. On Windows that file is written inside WSL, readable only by your WSL account.

ZestSSH does not write private keys to its logs.

After you generate or import a key, add its public key to each server you want to reach.

The quickest way: choose Install on hosts… on the key (on a computer, in the key’s details on the Keys page; on a phone, in the key’s editor), pick the hosts, and ZestSSH adds the public key to each host’s ~/.ssh/authorized_keys, the way ssh-copy-id does. See Install a key on hosts.

  1. Copy the public key: Copy public key in the key’s details on a computer copies it to the clipboard; on a phone, open the key, choose Manage SSH key, then Public.
  2. On the server, append it to ~/.ssh/authorized_keys:
Terminal window
echo "ssh-ed25519 AAAA... user@ZestSSH" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

An RSA key’s public line starts with ssh-rsa.

Make sure the SSH server allows public key authentication:

# In /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
  • Replace on all n hosts…: makes a new key and, host by host, adds it to authorized_keys, proves it signs in, and only then takes the old key’s line out and points the host at the new key. A host where a step fails keeps the old key working. See Replace a key on all its hosts.
  • Replace key (computer, in More actions; Rotate in the key’s form): replaces the key’s private key with a new or imported one through Set up SSH key. The hosts that use the key keep using it. Install the new public key on your servers first.
  • Passphrase: add, change or remove the key’s passphrase. See Add, change or remove a passphrase.
  • Duplicate (computer: right-click the key; phone: swipe the key, or long-press it and tap Key actions): makes a copy with what it signs in with, so the same key can sign in as another username. Allow unattended runs stays off on the copy. Keys held by an SSH agent are not copied this way.
  • Allow unattended runs: a switch on each saved key. Scheduled tasks and other automation that run with nobody there sign in only with keys that have it on. See Automation.

A passphrase adds a second lock: someone who copies the key file also needs the passphrase.

  • ZestSSH sees that a key has a passphrase when you import it or connect with it.
  • When it asks, you can save the passphrase with the key, so it is not asked for again.
  • A wrong passphrase stops the connection with: “The passphrase did not open the private key of “key name”. Connect again to enter it once more.”
  • The generator does not set a passphrase, but you can add one to any key afterwards with Passphrase (on a computer, Add one under Protection in the key’s details).
  • A passphrase saved with a key that no longer has one (removed on another device) is not used: the key opens without it.
  • OpenSSH certificates: import or generate a user certificate and attach it to a key. See OpenSSH certificates.
  • FIDO2 hardware keys and SSH agents: on a phone, sign in with a key on a security key held to it or plugged in; on a computer, with keys held by your system’s SSH agent, 1Password or Bitwarden. See FIDO2 hardware keys.

“The private key of … is not on this device”

Section titled ““The private key of … is not on this device””

The full message is: “The private key of “key name” is not on this device: it was removed, or its import did not finish. Open the key and import its private key again.” Import the key again from your backup, or set up a new one.

“The private key of … on this device cannot be read”

Section titled ““The private key of … on this device cannot be read””

The key file in storage is damaged, or of a kind ZestSSH does not know. Nothing was sent to the host. Import the private key again.

ZestSSH shows Key authentication failed: “The server rejected your SSH key.”

  • Check that the public key is in ~/.ssh/authorized_keys on the server, for the account you sign in as.
  • Check permissions: ~/.ssh must be 700 and authorized_keys 600.
  • Make sure the server’s sshd_config has PubkeyAuthentication yes.
  • Check that AllowUsers or AllowGroups does not block your user.
  • Read the server’s log (/var/log/auth.log or journalctl -u sshd).
  • A server older than OpenSSH 7.2 takes RSA signatures only with SHA-1. Turn on Compatibility mode for that host (under Auth in a computer’s host editor, behind Advanced options on a phone), or use a key of another kind.
  • Check that the right public key is on that server.

Q: Which key type should I choose? A: Ed25519 for most people. It is fast, compact, and every current SSH server takes it (OpenSSH 6.5 and later). Use RSA 4096 only for servers that need RSA.

Q: Can I use the same key for several servers? A: Yes. Pick the same key in each host’s Key field and add its public key to authorized_keys on each server.

Q: Can I export my private key? A: Yes, on a computer and on a phone: Export… writes OpenSSH key files, and you choose whether the private key file has a passphrase. Your keys are also in your encrypted backups.

Q: Can ZestSSH convert a PuTTY key? A: Yes. Importing a .ppk file (RSA or Ed25519) converts it to an OpenSSH key.

Q: What happens if I lose my private key? A: If it is in none of your devices, your sync or your backups, it cannot be recovered. Make a new key and add its public key to your servers.