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#

BASH
zensailor login

The 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.

BASH
zensailor logout          # forget the token of the active server
zensailor server list     # the saved servers, and which one is active

In a script, pipe the token in or set ZENSAILOR_TOKEN. A token is never a command-line argument, because shell history would keep it:

BASH
printf '%s' "$TOKEN" | zensailor login prod --url https://sail.example.com --token-stdin

Several servers#

The CLI keeps a named login for each instance. One of them is active:

BASH
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 homelab

Pick a server for a single command with --server or ZENSAILOR_SERVER:

BASH
zensailor --server prod service deploy <service-id>
ZENSAILOR_SERVER=prod zensailor service list

A 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:

BASH
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#

BASH
zensailor completion bash     # or: zsh, fish

Add 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.