Environment variables
A host can carry environment variables, KEY=value pairs that ZestSSH exports in the shell each time you connect to it. Use them for an application’s mode (NODE_ENV, RAILS_ENV), a log level, or any setting your tools on the server read.
Add a variable
Section titled “Add a variable”- Open the host’s editor. On a computer, go to Advanced. On a phone, tap Advanced options.
- Find the Environment section and tap + Add.
- Type the name on the left (for example
APP_ENV) and the value on the right (for examplestaging). - Add more the same way. The × at the end of a row removes it.
- Save the host.
A name may hold only letters, digits and underscores, and must not start with a digit. The name field takes no other characters, and a name that starts with a digit shows Invalid name. A row with an empty name is not saved.
A change counts from your next connection to the host. A session that is already open keeps what it had.
What happens when you connect
Section titled “What happens when you connect”As soon as the session is up, ZestSSH types one line into the shell and runs it:
export APP_ENV='staging'; export LOG_LEVEL='debug'; clearThe clear at the end wipes the screen, so your first prompt is not crowded by the exports. Then the host’s Startup command (optional) runs, if it has one, and then its Run snippet (optional).
Each value is put in single quotes. A single quote inside a value is written as '\'', so the value stays one piece of text. For example, the value it's a "test" is exported as:
export MY_VAR='it'\''s a "test"'Inside single quotes the shell expands nothing. A value of /opt/tools/bin:$PATH sets the variable to exactly that text, with a literal $PATH. If you need the shell to expand something, put the command in the host’s Startup command (optional) instead, for example export PATH=/opt/tools/bin:$PATH.
Sync and backups
Section titled “Sync and backups”The variables are part of the host, so they go wherever the host goes: through sync and in backups. When a host arrives from another device or a backup, ZestSSH checks its variables again:
- a name that breaks the naming rule is dropped,
- a value with a control character (a line break, a tab) or longer than 4,096 characters is dropped,
- past 64 variables, or about 16 KB of names and values together, the rest is dropped.
Good to know
Section titled “Good to know”- The exports are typed into the shell like a command you type, so a shell that keeps a history file may save the line.
- A local host is different: from 4.3 its variables go into the environment of the shell or program as it starts, and are never typed. A device asks before it first runs a local host that has them.
- Do not put passwords or tokens in a variable. The host’s editor shows every value in the open, to anyone who opens the host.
- The variables are not sent with SSH’s own environment request, so the server’s
AcceptEnvsetting does not matter. The remote shell must understandexport. - Automation runs (a
zestssh://link, a workflow step, a scheduled task) run one command without a terminal. They do not export the host’s variables and do not run its startup command.
Next steps
Section titled “Next steps”- tmux auto-attach: the host’s startup command.
- Snippets: run a snippet each time you connect.