Skip to content

API authentication

Every automation request to ZestSSH must carry one of your API keys. This page covers how keys are made, passed, checked and removed. The API keys page has the same steps with more on where keys are stored.

A key is shown once, when you make it, and ZestSSH keeps only a hash of it. Copy it then: it cannot be shown or copied again.

API keys live on the device that made them: a key made on your phone does not work on your computer.

On a computer:

  1. Open Automation in the sidebar and choose the API keys tab.
  2. Click Create API key.
  3. Fill in Label (up to 64 characters), Expires in (30 days, 90 days, 180 days, 1 year or Never; 90 days is chosen first) and Scope (All hosts, or one host with Specific host).
  4. Click Create.
  5. In Save your API key, copy the key with Copy to clipboard, tick I’ve copied this key somewhere safe, then click Done.

On a phone:

  1. Open More > Automation and turn on External automation.
  2. Tap API keys, then + (or Create API key when you have none).
  3. Fill in Label and Expiration (Never, 30 days, 60 days, 90 days, or Custom for a date up to a year away; Never is chosen first).
  4. Tap Create. In Save your API key, copy the key with Copy to clipboard, tick I’ve copied this key somewhere safe, then tap Done.

A key made on a phone has no scope: it works on every host.

  • Length: 48 characters
  • Characters: a-z, A-Z, 0-9 (62 in all)
  • Entropy: about 285 bits
  • Generator: Dart’s Random.secure(), the system’s secure random generator
Field Description
ID A UUID, used inside the app (a scheduled task stores this, not the key)
Label Your name for the key
Hash The SHA-256 of the key. The key itself is not stored
Hint The key’s last 4 characters, shown after dots so you can tell keys apart
Created When it was made
Last used Set each time it lets a request in
Expires When it stops working, if you set an expiry
Scope The one host it is limited to, if any

These are kept in the system’s secure storage on this device. Keys made with an earlier version, which stored the key itself, keep working; the first start of this version stores them as a hash and a hint only.

Add the key as the key parameter:

zestssh://execute?connection=web-01&command=uptime&key=YOUR_API_KEY

The key is checked after you tap Run in Run this from a link?.

Add the key as the key extra:

Extra: key:YOUR_API_KEY

A scheduled task (Android) stores only the ID of the key you pick. When it runs, ZestSSH checks that a key with that ID is still there and has not expired. The ID is not a secret: it is taken only together with a one-time launch token that ZestSSH’s own scheduler hands over, so another app that learned the ID cannot use it.

A link with your key as key, opened from a shortcut with an Open URLs action, carries it to ZestSSH. See iOS Shortcuts.

A link or an intent carries the key itself, so anything that holds the link or the task holds the key.

  • On Android, zestssh:// is claimed by a plain link filter, not a verified web address. Another app that also claims zestssh:// can be offered your link. An intent with Package set to com.affluentlabs.zestssh and Target set to Activity goes to ZestSSH.
  • A Tasker task, a shortcut or a script keeps the key as you typed it. Do not share or publish one that holds a real key.
  • A key you copy from ZestSSH is taken off the clipboard 45 seconds later.
  1. Compare: the key you sent is hashed with SHA-256 and compared with each stored hash in constant time, so how long the check takes says nothing about how much of a key was right.
  2. Expiry: a key that matches but has expired is refused, and counts as a failed attempt.
  3. Lockout: consulted only when no key matched (see below). A valid, unexpired key always works, even during a lockout.
  4. Mark used: a key that lets a request in has its last-used time set, in the same step.
  5. Scope: a key limited to one host refuses a request for any other host, a batch with any other host in it, and every workflow.

When a key is refused, ZestSSH’s notice says “The request came with no API key of this device’s, or with one that has expired, so the command was not run.” For a scoped key used on another host it says “The request’s API key is limited to one host, so what it asked for was not run.”

Condition Effect
No key matched, no lockout running Failure count goes up by one
5 failures Unknown keys are locked out for 1 minute
10 failures Locked out for 5 minutes
15 or more failures Locked out for 30 minutes (the longest)
No key matched during a lockout Refused, and the count does not go up
A valid key Count back to 0, any lockout cleared

The count and the end of the lockout are kept in secure storage, so restarting the app does not reset them. When the app starts after a lockout has ended, the count starts again from 0.

  1. Create a new key with a clear label, for example “Tasker 2”.
  2. Copy it from Save your API key into every task, shortcut or script that used the old one.
  3. Run one of them to check it.
  4. Revoke the old key.

Creating a key does not change the keys you have.

ZestSSH cannot show or copy a key again, because it keeps only the key’s hash. A row shows only the key’s last 4 characters. If you no longer have a key, make a new one, put it where the old one was used, and revoke the old one.

  • On a computer: click Revoke on the key’s row, then Revoke key in Revoke “label”?.
  • On a phone: open the card’s menu, tap Delete, then Delete in Delete key?.

The key is removed at once, and every request that carries it is refused from then on. This cannot be undone.

  1. One key per app or purpose, so you can revoke one without touching the others.
  2. Limit a key to one host (on a computer, Specific host) when it only needs one.
  3. Let keys expire when you use them for a while only.
  4. Look at last-used times and revoke keys you no longer use.
  5. Turn on the app lock, so nobody can open ZestSSH on your device to make keys. See App lock.
  6. Keep each key where it is used, or in your password manager: ZestSSH cannot show it again.