Skip to main content

termix snippets and termix credentials

Manage saved commands and saved logins.

termix snippets​

Snippets are commands you saved so you do not have to retype them. See Snippets.

List snippets​

termix snippets
termix snippets list

Create a snippet​

termix snippets create --name "Restart nginx" --content "systemctl restart nginx"
termix snippets create --name "Deploy" --content-file ./deploy.sh
OptionWhat it does
--name <name>Name. Required
--content <content>The command itself
--content-file <path>Read the command from a file
--description <text>Description
--folder <folder>Folder to file it under

Give either --content or --content-file, not both. --content-file is much easier for anything more than one line.

Update a snippet​

termix snippets update 5 --content "systemctl reload nginx"

Only what you pass changes. Same options as create.

Delete a snippet​

termix snippets delete 5

Run a snippet​

termix snippets run 5 --host 3
OptionWhat it does
--host <hostId>Host to run it on. Required
--input <NAME=VALUE>Fill in a snippet input. Repeat for more than one
termix snippets run 5 --host 3 --input ENVIRONMENT=production --input VERSION=1.4.0

Inputs must be written NAME=VALUE. The exit code is the one from the server, same as termix exec.

termix credentials​

Credentials are saved logins you can attach to several hosts, so a password lives in one place. See Credentials.

List credentials​

termix credentials
termix credentials list

Show one credential​

termix credentials get 4

Create a credential​

TERMIX_CREDENTIAL_PASSWORD='secret' termix credentials create \
--name "Deploy user" --auth-type password --username deploy
OptionWhat it does
--name <name>Name. Required
--auth-type <type>password or key. Required
--username <username>Username. Required
--description <text>Description
--folder <folder>Folder
--tags <tags>Comma separated tags
--key-file <path>Private key file, for key type
--password <password>Password. Prefer the environment variable
--key-password <passphrase>Passphrase for the key

Pass secrets with TERMIX_CREDENTIAL_PASSWORD and TERMIX_CREDENTIAL_KEY_PASSWORD instead of flags, so they stay out of your shell history and the process list.

With a key:

termix credentials create --name "Deploy key" --auth-type key \
--username deploy --key-file ~/.ssh/id_ed25519

Update and delete​

termix credentials update 4 --name "Deploy user (prod)"
termix credentials delete 4

Update changes only the fields you pass.

Using a credential on a host​

termix hosts create --ip 10.0.0.5 --username deploy --credential-id 4

Better than putting the password on each host, since changing it once updates every host that uses it.

termix inject​

Runs a local command with credentials in its environment. Nothing is written to disk.

termix inject 4 7 -- ./deploy.sh
termix inject --mask 4 -- npm run migrate
termix inject --names 4 -- python sync.py

Each credential sets TERMIX_<ID>_USERNAME, TERMIX_<ID>_PASSWORD and TERMIX_<ID>_KEY, for the parts it has. --names also sets variables named after the credential, like DEPLOY_USER_PASSWORD. It stops with an error if one of those names is already set or two credentials give the same name.

--mask replaces the secrets with [REDACTED_BY_TERMIX] in the command's output. The last few characters of output may show up a moment later, since Termix holds them back to catch a secret split between writes.

The exit code is the command's own. If the command is killed by a signal, it is 128 plus the signal number, like 137 for SIGKILL.