Skip to main content
Open an interactive SSH session to a Lager Box, or run a single command on it and return.

Syntax

Options

Arguments


Usage

Run a command on the box

With a COMMAND, lager ssh behaves like ssh user@host <command>. It runs the command on the box, streams its output back, and exits with the command’s exit code. There is no interactive shell. This is handy for scripting and one-off checks.
lager ssh with a COMMAND does not allocate a terminal. A remote sudo command therefore works only when the box user has a passwordless grant for it. Otherwise, run it in an interactive session.
Use -- to separate lager’s options from the remote command whenever the command contains its own dashed flags, so they aren’t parsed as lager options. The remote command’s exit code is propagated as lager ssh’s exit code, so it composes cleanly in scripts.

How It Works

The command:
  1. Resolves the Lager Box name to IP address
  2. Looks up the SSH username (default: lagerdata)
  3. Chooses the SSH identities to offer
  4. Opens an interactive SSH session, or runs the command
If ~/.ssh/lager_box exists, lager ssh passes it with -i. The -i flag replaces the default identity list of SSH instead of adding to it. So lager ssh also names each of your own default keys that exists, after lager_box. Those keys are id_rsa, id_ecdsa, id_ecdsa_sk, id_ed25519 and id_ed25519_sk. Identities from ~/.ssh/config and agent keys stay on offer. With no lager_box key, lager ssh passes no -i at all.

Username Resolution

SSH usernames are resolved in order:
  1. Username stored with box configuration (lager boxes add --user)
  2. Default username: lagerdata
lager ssh looks up the stored username by box name. For an IP address in --box, or for the default box, it uses the username of the saved box with that IP address. To use a different username for a Lager Box:

SSH Key Setup

For passwordless access, install the Lager SSH key on the box. The command asks for the box password once:
A key that you installed yourself with ssh-copy-id also works, because lager ssh offers your default keys too. See SSH Setup.

Examples


Common Tasks via SSH

Each of these can be run as a one-liner with lager ssh --box <box> -- <command>, or interactively after lager ssh --box <box>.

Check Container Status

View Lager Box Version

Check Disk Space

View Firewall Status

sudo asks for a password on most boxes, so open an interactive session first:

Notes

  • With no COMMAND, opens a fully interactive shell session (exit with exit or Ctrl+D)
  • With a COMMAND, runs it on the box and exits with the command’s exit code
  • The session runs as a child process so Lager’s cleanup hooks still fire
  • Default Lager Box is used if --box not specified