> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sailresearch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect

> Open a shell, run commands, or use SSH on a running Sailbox.

Connect to an existing Sailbox by its ID. Read `sb.sailbox_id` in Python or `sb.sailboxId` in TypeScript, or run `sail box list`.

## Run a command

```bash CLI theme={null}
sail box exec <id> -- uname -a
```

```python Python theme={null}
import sail

sb = sail.Sailbox.get("sb_...")
print(sb.run("uname -a").stdout)
```

```typescript TypeScript theme={null}
import { Sailbox } from "@sailresearch/sdk";

const sb = await Sailbox.get("sb_...");
console.log((await sb.run("uname -a")).stdout);
```

`get` looks up the Sailbox without waking it. A command wakes a sleeping
Sailbox automatically. A manually paused Sailbox needs an explicit
[resume](https://docs.sailresearch.com/sailboxes-lifecycle.md#resume) first.

For streaming output and background commands, see [exec](https://docs.sailresearch.com/sailbox-sdk.md#exec).

## Open a shell

```bash theme={null}
sail box shell <id>
```

This opens a terminal inside the Sailbox. It needs no exposed port or SSH
setup. Run `exit` to leave; the Sailbox keeps running.

`sail shell` is different: it opens an interactive CLI on your own machine
for managing Sailboxes. See [CLI](https://docs.sailresearch.com/reference/cli.md#interactive-shell).

## Use SSH

```bash theme={null}
sail box ssh enable <id>
ssh <name>.sail
```

The first command enables SSH and adds a shortcut to your local SSH config.
Use the Sailbox's name in place of `<name>`. You connect as `root`.

For a Sailbox that already has SSH enabled, set up this machine's shortcut:

```bash theme={null}
sail box ssh alias <id>
```

SSH exposes port 22. See [access control](https://docs.sailresearch.com/sailboxes-access-control) for
source restrictions, or use a [devbox](https://docs.sailresearch.com/sailboxes-devboxes) to set up SSH and
development tools together.
