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.
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 (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).
- 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.
On a phone:
- Open More > Automation and turn on External automation.
- Tap API keys, then + (or Create API key when you have none).
- 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).
- 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.
Key properties
Section titled “Key properties”- 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
What is stored with a key
Section titled “What is stored with a key”| 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.
Passing the key
Section titled “Passing the key”In a link
Section titled “In a link”Add the key as the key parameter:
zestssh://execute?connection=web-01&command=uptime&key=YOUR_API_KEYThe key is checked after you tap Run in Run this from a link?.
In an Android intent
Section titled “In an Android intent”Add the key as the key extra:
Extra: key:YOUR_API_KEYIn a scheduled task
Section titled “In a scheduled task”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.
From iOS Shortcuts
Section titled “From iOS Shortcuts”A link with your key as key, opened from a shortcut with an Open URLs action, carries it to ZestSSH. See iOS Shortcuts.
Keeping the key private
Section titled “Keeping the key private”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 claimszestssh://can be offered your link. An intent with Package set tocom.affluentlabs.zestsshand 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.
How a key is checked
Section titled “How a key is checked”- 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.
- Expiry: a key that matches but has expired is refused, and counts as a failed attempt.
- Lockout: consulted only when no key matched (see below). A valid, unexpired key always works, even during a lockout.
- Mark used: a key that lets a request in has its last-used time set, in the same step.
- 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.”
Rate limiting
Section titled “Rate limiting”| 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.
Rotating a key
Section titled “Rotating a key”- Create a new key with a clear label, for example “Tasker 2”.
- Copy it from Save your API key into every task, shortcut or script that used the old one.
- Run one of them to check it.
- Revoke the old key.
Creating a key does not change the keys you have.
Lost a key?
Section titled “Lost a key?”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.
Revoking a key
Section titled “Revoking a key”- 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.
Best practices
Section titled “Best practices”- One key per app or purpose, so you can revoke one without touching the others.
- Limit a key to one host (on a computer, Specific host) when it only needs one.
- Let keys expire when you use them for a while only.
- Look at last-used times and revoke keys you no longer use.
- Turn on the app lock, so nobody can open ZestSSH on your device to make keys. See App lock.
- Keep each key where it is used, or in your password manager: ZestSSH cannot show it again.