Documentation
Phone notifications for SSH and remote server jobs
Get a phone alert after an SSH build, backup or long-running Linux job. Pair a server independently, preserve exit codes and handle sessions that disconnect.
Updated
Choose where the notification runs
#You can notify from your laptop after an SSH command returns, or from the server when its own job exits. These choices have different failure boundaries. The laptop approach needs only its existing Ntfyx connection, but a broken SSH connection may give you a transport error rather than a known job result.
A paired server can notify independently of the laptop if the job itself remains running.
| Run the wrapper on | Useful for | Important boundary |
|---|---|---|
| Your laptop | A foreground SSH command | Disconnect can hide the remote result. |
| The paired remote host | An existing persistent or scheduled job | The host and outbound network must remain available. |
| An unpaired CI runner | An existing public Topic or private HTTPS webhook | Public content is readable; HTTPS input is service-readable; store keys privately. |
Before you connect
#Use current Ntfyx CLI 0.6.1 on Windows, macOS or Linux and a primary phone app. iPhone 1.8.3 is available on the App Store; Android 1.8.2 is available on Google Play. Android push requires Google Play services. The phone authorizes each computer or server as its own Source; an optional Web Inbox receives new messages after phone authorization.
curl -fsSL https://ntfyx.me/install.sh | bash
ntfyx connect
ntfyx topicsNotify when a foreground SSH command returns
#Save the complete script below as notify-ssh.sh. From the paired computer run bash notify-ssh.sh Work YOUR_HOST 'cd /path/to/project && npm run build'. SSH returns 255 on error, which cannot establish whether the remote job failed or stopped; a remote program may also return 255. The wrapper preserves that status and reports the outcome as unknown.
#!/usr/bin/env bash
# Save as notify-ssh.sh. Usage: bash notify-ssh.sh TOPIC HOST 'COMMAND'
set -u
if [ "$#" -lt 2 ]; then
printf 'Usage: bash notify-ssh.sh TOPIC HOST [COMMAND]\n' >&2
exit 2
fi
ntfyx_topic="$1"
shift
ssh "$@"
ntfyx_ssh_status=$?
case "$ntfyx_ssh_status" in
0) ntfyx_title='SSH command finished'
ntfyx_body='SSH returned status 0. Check the remote result and log.' ;;
255) ntfyx_title='SSH result unknown'
ntfyx_body='SSH returned 255. Check the connection and remote job before rerunning it.' ;;
*) ntfyx_title='SSH command failed'
ntfyx_body="SSH returned status $ntfyx_ssh_status. Check the remote log." ;;
esac
if ! ntfyx send "$ntfyx_body" --title "$ntfyx_title" --topic "$ntfyx_topic" >/dev/null; then
printf 'Notification not confirmed; SSH exit status is preserved.\n' >&2
fi
exit "$ntfyx_ssh_status"Pair the server as its own Source
#Install the supported CLI on the remote Linux or macOS host, run connect there, then scan its temporary QR with the phone. Choose an existing protected Topic or create one within the shared technical limit. Keep the QR private and pair as the same user that runs the job. Ntfyx does not connect inbound to your server or start a new SSH tunnel.
# Run on the remote host, as the job owner.
curl -fsSL https://ntfyx.me/install.sh | bash
ntfyx connect
ntfyx send "Server connection ready" --topic WorkLet an existing job notify independently
#Put notify-after.sh on the paired server and call it from your existing tmux session, scheduler or service. This wrapper reports a command result; it does not keep the process alive, restart a failed job, or detect a scheduler that never ran. Cron needs explicit PATH and absolute paths. Keep logs on the server, and configure your job supervisor separately if you need persistence.
# Run in your existing persistent session on the paired server.
bash /path/to/notify-after.sh Work bash -c 'printf "Remote demo finished\n"'Request a decision without opening remote shell access
#A server script can ask for Allow/Deny, a named choice or short text. Your answer goes back to that request, not into an unrestricted interactive shell. Review context, stop on expiry or verification failure, and never execute arbitrary reply text. There is no built-in team escalation or infrastructure incident SLA.
ntfyx ask "Which environment should I inspect?" \
--choice staging=Staging --choice production=Production \
--topic Work --wait 60s --expires 90s --jsonStart with a use case
#From agent questions to weekly subscriptions and website alerts, start with a use case. See what reaches your phone, then follow the steps to connect.
After a disconnect, inspect the remote job before rerunning
#Use the original task log or existing process supervisor to determine whether the job is running, finished or failed before deciding what to do. A broken local SSH connection does not establish remote completion. For laptop-independent alerts, run notify-after.sh on the server as the task owner through its existing persistent session or scheduler.
It still cannot detect host power loss or a job that never started. Exercise normal and failed exits, then separately test your own disconnect scenario.