Getting Started with the CLI
Authentication, configuration and shell completion.
Once installed (see CLI Overview), the first thing to do is authenticate and verify the connection.
Login#
zensailor loginThe interactive flow asks for your instance URL and an API token (create
it in the dashboard under Settings → Security). The CLI stores the pair
in ~/.zensailor/config.json with owner-only file permissions.
zensailor logout # forget the token of the active server
zensailor server list # the saved servers, and which one is activeIn a script, pipe the token in or set ZENSAILOR_TOKEN. A token is never a
command-line argument, because shell history would keep it:
printf '%s' "$TOKEN" | zensailor login prod --url https://sail.example.com --token-stdinSeveral servers#
The CLI keeps a named login for each instance. One of them is active:
zensailor login prod --url https://sail.example.com
zensailor server add lab https://sail.lab.local --insecure
zensailor server use lab
zensailor server rename lab homelab
zensailor server remove homelabPick a server for a single command with --server or ZENSAILOR_SERVER:
zensailor --server prod service deploy <service-id>
ZENSAILOR_SERVER=prod zensailor service listA name that isn't saved stops the command instead of falling back to the active
server. With more than one server saved, each command names the server it acts on
as a Server: line on stderr, so piped and parsed output doesn't change.
In zensailor system set-dns, --server lists DNS servers. To pick the instance
there, put it first: zensailor --server prod system set-dns --server 1.1.1.1.
Self-signed instances#
Home-lab and LAN installs use self-signed certificates. Pass the global
--insecure flag when you add the server. It is remembered for that server, so
later commands don't need it:
zensailor login lab --url https://sail.lab.local --insecure
zensailor --server lab service deploy <service-id>To verify TLS again once the instance has a trusted certificate, log in with
zensailor login lab --secure.
Shell completion#
zensailor completion bash # or: zsh, fishAdd the output to your shell's rc file, and zensailor's commands and flags autocomplete from then on.
Mistakes are cheap: most destructive commands (service rm, node rm,
backup deletes) prompt for confirmation. Non-interactive scripts should pass
--yes/--confirm explicitly when the docs for the command show it.