Skip to content

MacroDroid integration

MacroDroid is an Android automation app that can open a zestssh:// URL with its “Open Website / URL” action. Android hands the URL to ZestSSH, which runs the command, snippet, batch or workflow it names.

  1. MacroDroid opens a zestssh:// URL, and Android routes it to ZestSSH.
  2. ZestSSH shows Run this from a link?, naming what would run and on which host, and waits.
  3. When you tap Run, ZestSSH checks the API key in the URL, signs in to the host, runs the command, and logs the result in its automation history.

Any app or web page can open a URL, so a URL never runs before you tap Run. A macro on a timer or an NFC tag therefore stops at that question until you answer it.

To run with nobody at the phone, send ZestSSH an Android intent instead of opening a URL: an intent runs without the question. ZestSSH takes the intent from any app that sends it to its activity. The actions and extras are on the Tasker integration page.

Whichever way you use, a run signs in only with SSH keys switched to Allow unattended runs in Keys, and only to hosts whose host key this device already trusts.

  1. Open ZestSSH and go to More > Automation. Turn on External automation (needs Squeezed).
  2. Tap API keys, then + (or Create API key).
  3. Enter a label, for example “MacroDroid”.
  4. Optionally pick an expiration.
  5. Tap Create. In Save your API key, copy the key, tick I’ve copied this key somewhere safe, and tap Done. You need the key for the URL, and ZestSSH shows it only this once.
  1. Open MacroDroid and tap Add Macro.
  2. Add Trigger: choose any trigger (a time, an NFC tag, a widget button, and so on).
  3. Add Action: select Applications > Open Website / URL.
  4. Paste your zestssh:// URL into the URL field (see the URL formats below).
  5. Uncheck Use Built-in Browser, so the URL goes to ZestSSH and not to a web view.
  6. Save the macro.

Tap the macro’s play button. ZestSSH opens and asks Run this from a link?. Tap Run. The result is in More > Automation > Automation history.

zestssh://execute?connection=HOST_NAME&command=COMMAND&key=API_KEY

Optional: timeout (seconds, default 30, up to 300), grep (filter pattern), head (first N lines), tail (last N lines).

zestssh://snippet?connection=HOST_NAME&name=SNIPPET_NAME&key=API_KEY

Optional: var_NAME=value for each {{NAME}} or ${NAME} in the snippet. The question shows the snippet’s command with your values filled in.

zestssh://batch?connections=HOST1,HOST2,HOST3&command=COMMAND&key=API_KEY

Optional: parallel=true (default) or parallel=false, timeout, grep, head, tail.

zestssh://workflow?name=WORKFLOW_NAME&key=API_KEY

Or by ID: zestssh://workflow?id=WORKFLOW_ID&key=API_KEY.

These take no API key and run nothing by themselves:

  • zestssh://connect?name=HOST_NAME asks Connect to HOST_NAME? and opens a session to that saved host when you tap Connect.
  • zestssh://connect?host=192.168.10.5&user=alex&port=22 opens Quick connect with that address typed in.

A callback parameter on a zestssh:// URL is ignored. ZestSSH sends a webhook only for a request that arrives as an Android intent (see the Tasker page).

Trigger: a time trigger, every day at 7:00 AM. Action: Open Website / URL:

zestssh://execute?connection=web-01&command=uptime%20%26%26%20df%20-h%20%2F&key=YOUR_API_KEY

(The command, URL-encoded, is uptime && df -h /.)

Trigger: a MacroDroid widget button. Action: Open Website / URL:

zestssh://snippet?connection=docker-01&name=Restart%20container&var_DOCKER=nginx-proxy&key=YOUR_API_KEY

Trigger: any trigger. Action: Open Website / URL:

zestssh://batch?connections=web-01,web-02,db-01&command=df%20-h%20%2F&parallel=true&key=YOUR_API_KEY

Trigger: an NFC tag scan. Action: Open Website / URL:

zestssh://execute?connection=staging-01&command=cd%20%2Fapp%20%26%26%20git%20pull&key=YOUR_API_KEY

Special characters in a command must be URL-encoded. Common ones:

Character Encoded
space %20
/ %2F
& %26
= %3D
| %7C

A URL longer than 2,048 characters, or with any value longer than 256 characters, is refused. Put a long command into a snippet and run the snippet.

The quickest way to a correct URL is ZestSSH’s Automation wizard:

  1. Go to More > Automation > Automation wizard (shown while automation is on).
  2. Walk through the steps: the action, the host, the command, and any filters.
  3. In Your automation, the MacroDroid card has the setup steps, and its copy button copies the URL. Where the URL says YOUR_KEY, paste your API key, or use Make a new key for this to make one that the URL then holds until you close the wizard.
  • Keep your URLs private: anyone with the URL and its key can ask ZestSSH to run commands on your hosts.
  • For several steps, run a workflow URL instead of chaining macros.