Tasker examples
These examples run ZestSSH automation from Tasker with Tasker’s System > Send Intent action. Replace YOUR_API_KEY with your own key, and the host names with your own.
Why an intent, not a link
Section titled “Why an intent, not a link”A zestssh:// link always asks Run this from a link? and waits for you to tap Run, so a Tasker task that opens a link stops at that question. An intent runs without asking, which is what a timed or triggered task needs. Every example here uses an intent.
Before you start
Section titled “Before you start”- In ZestSSH, open More > Automation and turn on External automation (needs Squeezed).
- Tap API keys and create a key for Tasker. Copy it when Save your API key shows it: it is shown only once.
- In Keys, open the key each host signs in with and turn on Allow unattended runs. Do the same for the keys of the host’s jump hosts.
- Connect to each host yourself once, so ZestSSH trusts its host key.
In every Send Intent action:
- Action: one of the ZestSSH actions below
- Package:
com.affluentlabs.zestssh - Target: Activity
- Each extra in an Extra field of its own, as
name:value
The Tasker integration page lists every extra. More > Automation > Automation wizard builds the intent for you and gives it as a Tasker intent card to copy, with YOUR_KEY where your key goes (or a key you make there with Make a new key for this).
Getting the result
Section titled “Getting the result”ZestSSH hands stdout and exit_code back only to an app that started it for a result. To act on a command’s result whatever starts the task, add a callback extra with an HTTPS address: when the command ends, ZestSSH POSTs the result there as JSON (see Webhook callback). A push service that takes a POST can then notify your phone. Every run is also in More > Automation > Automation history.
callback works with EXECUTE and BATCH only.
Example 1: daily disk check
Section titled “Example 1: daily disk check”Goal: every morning, send the disk use of web-01 to your push service.
Tasker profile: a time trigger, every day at 07:00.
Task:
Action: System > Send Intent Action: com.affluentlabs.zestssh.EXECUTE Package: com.affluentlabs.zestssh Target: Activity Extra: key:YOUR_API_KEY Extra: connection_id:web-01 Extra: command:df -h / | tail -n 1 Extra: timeout:15 Extra: callback:https://hooks.example.com/zestsshtail -n 1 keeps the last line that df prints, the line for /.
Example 2: start a backup when you leave home
Section titled “Example 2: start a backup when you leave home”Goal: when your phone leaves your home Wi-Fi, start a backup script on nas-01.
Tasker profile: Tasker’s Wi-Fi connected state for your home network, inverted.
Task:
Action: System > Send Intent Action: com.affluentlabs.zestssh.EXECUTE Package: com.affluentlabs.zestssh Target: Activity Extra: key:YOUR_API_KEY Extra: connection_id:nas-01 Extra: command:/opt/scripts/backup.sh Extra: timeout:300 Extra: callback:https://hooks.example.com/zestsshA run waits at most 300 seconds, so a longer backup should start in the background on the server, for example with nohup /opt/scripts/backup.sh > /tmp/backup.log 2>&1 &. A run asks for nothing, so a command that needs sudo works only where the server lets it run without a password.
Example 3: deploy a branch with a snippet variable
Section titled “Example 3: deploy a branch with a snippet variable”Goal: deploy a chosen branch to staging-01 with a saved snippet.
In ZestSSH, save a snippet named deploy-branch with the command:
cd /var/www/app && git fetch && git checkout {{branch}} && git pull && docker compose up -d --buildAutomation fills {{branch}} from the var_branch extra, shell-escaped. A snippet written with the snippet editor’s ${branch} is filled the same way.
Task:
Action: Variable Set Name: %deploy_branch To: develop
Action: System > Send Intent Action: com.affluentlabs.zestssh.SNIPPET Package: com.affluentlabs.zestssh Target: Activity Extra: key:YOUR_API_KEY Extra: connection_id:staging-01 Extra: snippet_name:deploy-branch Extra: var_branch:%deploy_branchA snippet run waits at most 30 seconds, and takes no callback. Its result is in the automation history.
Example 4: update several servers
Section titled “Example 4: update several servers”Goal: run package updates on three servers.
Task:
Action: System > Send Intent Action: com.affluentlabs.zestssh.BATCH Package: com.affluentlabs.zestssh Target: Activity Extra: key:YOUR_API_KEY Extra: connections:web-01,web-02,db-01 Extra: command:apt-get update -qq && apt-get upgrade -y -qq Extra: parallel:true Extra: timeout:120 Extra: callback:https://hooks.example.com/zestsshWith parallel:true, at most 4 hosts run at once. The result has one section per host, headed === web-01 (exit=0) ===, and its exit code is 0 only when every host succeeded. The command runs as the user each host signs in as.
Example 5: hourly container check
Section titled “Example 5: hourly container check”Goal: every hour, report containers on docker-01 that have exited.
Tasker profile: a time trigger, every hour.
Task:
Action: System > Send Intent Action: com.affluentlabs.zestssh.EXECUTE Package: com.affluentlabs.zestssh Target: Activity Extra: key:YOUR_API_KEY Extra: connection_id:docker-01 Extra: command:docker ps -a --format '{{.Names}} {{.Status}}' Extra: grep:Exited Extra: timeout:15 Extra: callback:https://hooks.example.com/zestsshgrep:Exited keeps only the lines that contain “Exited”. The pattern is a regular expression matched in any letter case; a pattern longer than 256 characters, or one shaped to backtrack without end, is matched as plain text.
- One key per Tasker setup, so you can revoke it without breaking other automations.
- Keep long commands in snippets. An intent takes them as they are, but a snippet is easier to change in one place.
- Run a command yourself first in a ZestSSH terminal, to see what it prints.
- A timeout from 1 to 300 seconds: the default is 30, and larger values are cut to 300.
- Treat a task that holds your key like a password. Do not share or publish it.