# ssh

## Usage

```bash
bdy sandbox ssh|connect [options] <identifier> [args...]
```

## Arguments

| **Argument** | **Description** |
| :--- | :--- |
| `identifier` | Sandbox identifier (required) |
| `args` | Arguments passed to ssh and the remote command to run, e.g. -- -L 8080:localhost:8080 (required) |

## Options

| **Option** | **Description** |
| :--- | :--- |
| `-w, --workspace <domain>` | Workspace URL handle. Can be set via variable: BUDDY_WORKSPACE |
| `-p, --project <name>` | Project name. Can be set via variable: BUDDY_PROJECT |
| `-i, --identity <path>` | Private key file used for authentication (ssh -i) |
| `--print` | Print the ssh command instead of running it |
| `-h, --help` | display help for command |

## Examples

### Open a shell in the sandbox

```bash
bdy sb ssh sandbox-identifier
```

### Run a single command and exit

```bash
bdy sb ssh sandbox-identifier -- ls -la
```

### Forward a sandbox port to localhost

```bash
bdy sb ssh sandbox-identifier -- -L 8080:localhost:8080
```

### Authenticate with a specific private key

```bash
bdy sb ssh sandbox-identifier -i ~/.ssh/id_ed25519
```

### Print the ssh command instead of running it

```bash
bdy sb ssh sandbox-identifier --print
```


---
Original source: https://buddy.works/docs/cli/sandbox/ssh