Skip to main content

Every box has a full Linux shell and runs on Debian by default.

You can access that shell either through the SDK or directly over SSH.


SSH#

Connect to a box with:

When prompted for a password, use your Box API key.

For example:

Tip

You can also copy this command from the SSH button on the box details page in the Upstash Console.

SSH keys#

Instead of the password, you can log in with an SSH key. A key you add works for all boxes in your account or team.

  1. Create a key pair, if you don’t have one:

  2. In the Upstash Console, go to Box → Settings → SSH Keys, click New SSH Key, and paste the contents of ~/.ssh/upstash_box.pub.

  3. Connect with the private key:

If your key is one SSH tries by default, such as ~/.ssh/id_ed25519, you can leave out -i.

Note

You can also click Generate Key to have Upstash create the key pair. The private key is shown only once and isn’t stored, so save it right away.

Accepted key types are ed25519, ECDSA, their security-key (sk-) variants, and RSA keys of at least 2048 bits. An account can have up to 20 keys.


API#

Run a shell command#

A shell command resolves when the command finishes and gives you back the result and status.

If you need additional system tools, install them with Debian’s package manager inside the box.


Run a code snippet#

You can execute code inside of a box:


Check exit status#

If the command fails, the run status will be "failed" and its result contains the stderr output.


Chain commands#

Pass a full shell expression. Pipes, redirects, and chained commands all work as expected.


Hold a command open#

exec.command runs a command to completion. When you need to write to stdin, drive an interactive program through a terminal, or signal a process while it runs, start a live session instead.


Cancel a long-running command#

You can cancel a run to abort it. The status becomes "cancelled".


Retrieve logs#

After a command finishes, call logs() to get the full timestamped output for debugging or auditing.


Examples#

Install dependencies before a run#

Set up the environment with box.exec.command(), then hand off to the agent.

Run a build and extract artifacts#

Execute a build command, then download the output.

Health-check before handing off#

Verify the environment is usable before starting a longer agent task.