API keys
API keys authenticate every automation request in ZestSSH: a zestssh:// link (from the iOS Shortcuts app too), an Android intent from Tasker or another app, and a scheduled task. A request without one of your keys, or with one that has expired, is refused. Keys are made with a secure random generator, checked in constant time, rate limited, and can expire.
A key is shown once, when you make it. ZestSSH keeps only a hash of it, so nobody, you included, can see or copy the key again later. Copy it into the app that will use it, or into your password manager, before you close the dialog.
API keys live on the device that made them. A key made on your phone does not work on your computer.
Creating a key
Section titled “Creating a key”On a computer:
- Open Automation in the sidebar and choose the API keys tab.
- Click Create API key.
- Fill in:
- Label: a name for the key, up to 64 characters, for example “Tasker”.
- Expires in: 30 days, 90 days (the default), 180 days, 1 year, or Never.
- Scope: All hosts, or a single host picked with Specific host.
- Click Create.
- In Save your API key, copy the key with Copy to clipboard, tick I’ve copied this key somewhere safe, then click Done. Done stays dimmed until the box is ticked.
On a phone:
- Open More > Automation and make sure External automation is on.
- Tap API keys, then tap + (or Create API key when you have none).
- Fill in:
- Label: a name for the key, for example “MacroDroid”.
- Expiration: Never (the default), 30 days, 60 days, 90 days, or Custom (a date from tomorrow to a year from now).
- 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.
The phone’s form has no scope: a key made there works on all hosts.
Each key is a 48-character string of letters (a to z, A to Z) and digits, drawn from the system’s secure random generator (Random.secure()). That is about 285 bits of entropy.
Save your API key is the only place the whole key ever appears: “This is the only time this key is shown.” With recording mode on, the key shows as dots with a Reveal button. A key you copy is taken off the clipboard 45 seconds later.
A key limited to one host is a hard limit, not a hint:
- A request it carries for any other host is refused.
- A batch is refused unless every host in it is that host.
- A workflow is always refused, because a workflow can reach several hosts.
Keys made without a scope, and every key made on a phone, work on all hosts.
Key storage
Section titled “Key storage”Keys are kept in the system’s secure storage through FlutterSecureStorage:
- Android: EncryptedSharedPreferences, backed by the Android Keystore.
- iPhone and iPad: the Keychain, readable after the first unlock on this device only.
- Windows, macOS, Linux: the system’s own secure storage.
They are saved as one JSON list. Each entry has an id, its label, the hash (the SHA-256 of the key, as hex), the hint (the key’s last 4 characters, so a list can tell keys apart), createdAt, and where set lastUsedAt, expiresAt and scopeConnectionId. The key itself is not kept, so it cannot be read back out of storage either.
Keys made with an earlier version, which kept the key itself, keep working. The first time this version starts, it writes them again as a hash and a hint only. From then on they cannot be copied again either.
Validation
Section titled “Validation”When a request arrives, its key goes through these steps.
1. Constant-time comparison
Section titled “1. Constant-time comparison”The key that comes with the request is hashed with SHA-256 and compared with each stored hash. The two 32-byte hashes are compared in constant time:
result = 0for i in range(length): result |= a[i] ^ b[i]return result == 0How long the check takes says nothing about how much of a key was right.
2. Expiry
Section titled “2. Expiry”If a stored key matches, its expiresAt is checked. An expired key is refused and counts as a failed attempt.
3. Rate limit
Section titled “3. Rate limit”The lockout is consulted only after the comparison, on the failure path. A valid, unexpired key always works, even during a lockout, so another app sending bad keys cannot lock you out of your own automations. When no key matches:
- If a lockout is still running, the attempt fails without adding to the count.
- Otherwise the failure count goes up by one. At 5 failures every unknown key is locked out for 1 minute, at 10 for 5 minutes, and at 15 or more for 30 minutes (the longest).
The count and the lockout’s end are kept in secure storage, so restarting the app does not reset them.
4. Success
Section titled “4. Success”A valid key sets the failure count back to 0 and records the key’s last use. The check and the update are one step.
Managing keys
Section titled “Managing keys”On a computer, each row of the API keys tab shows the label, its scope (All hosts or the host’s name), the key’s last 4 characters after dots (for example •••• x7Qa), “Created” and “Used” times, and its expiry: “Never expires”, “Expired”, or “Expires: ” and the date. The Revoke button removes it. There is no copy button: the key is not kept.
On a phone, each card shows the label, the key’s last 4 characters after dots, “Created” and “Used” times (or “Never used”), and its expiry in the same words. Its menu has Rename and Delete.
Lost a key?
Section titled “Lost a key?”ZestSSH cannot show it again. Make a new key, put it into the automations that used the old one, then revoke the old key.
Revoking a key
Section titled “Revoking a key”- Computer: click Revoke on the row, then Revoke key in Revoke “label”?.
- Phone: open the card’s menu, tap Delete, then Delete in Delete key?.
The key is removed at once, and every automation that uses it fails from its next run. This cannot be undone: make a new key and put it into your automations.
Renaming a key
Section titled “Renaming a key”On a phone, choose Rename in a key’s menu. The key itself stays the same, and its expiry and scope are kept.
Scheduled tasks and keys
Section titled “Scheduled tasks and keys”A scheduled task (Android) stores only the ID of its key, never the key itself, so no key is written into WorkManager’s own database. When the task runs, ZestSSH checks that a key with that ID is still there and has not expired, and marks it used. The ID is not a secret and lets nothing in by itself: what lets the run in is a one-time launch token that ZestSSH’s own scheduler hands over with it, so another app that learned the ID cannot use it. A revoked or expired key stops its tasks.
Keys and unattended runs
Section titled “Keys and unattended runs”An API key lets a request in. The SSH key the host signs in with must also be switched to Allow unattended runs, or the run is refused. On a computer, pick the key in Keys, choose Edit, and turn it on under Unattended runs; on a phone, it is in the key’s editor once the key is saved. See Unattended runs.
Best practices
Section titled “Best practices”- One key per app: make a key for each automation app, so you can revoke one without touching the others.
- Limit keys to a host: on a computer, give a key the Specific host scope when it only needs one host.
- Let keys expire: pick an expiry for keys you use for a while, or on a shared device.
- Revoke unused keys: look for keys that were never used, or not for a long time.
- Keep keys private: a
zestssh://link, a Tasker intent or a shortcut holds the key itself. Do not post one publicly or commit it to version control. - Keep a copy where you use it: the app that runs the automation, or your password manager. ZestSSH cannot show a key again.
- Check the automation history for runs you do not expect.