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

# SSH Access

> Connect to your workspaces via SSH for terminal access, file transfer, and management.

# SSH Access

Every Rigbox workspace is a full Linux VM with SSH access. Connect from any terminal to get a shell or transfer files.

## Prerequisites

Before connecting via SSH, you need:

1. An SSH key pair on your local machine (e.g., `~/.ssh/id_ed25519`)
2. A Rigbox account with an API key
3. At least one running workspace

If you don't have an SSH key yet, generate one:

```bash theme={null}
ssh-keygen -t ed25519 -C "your-email@example.com"
```

***

## Register an SSH Key

To connect via SSH, you first need to register your public key with Rigbox.

Replace `<KEY_NAME>` with a label you'll recognize (for example, `laptop`).

```bash theme={null}
rig ssh add --name <KEY_NAME>
```

This reads your default public key (`~/.ssh/id_ed25519.pub`) and registers it automatically under the name you provide. To register a key from a different path, pass `--file`:

```bash theme={null}
rig ssh add --name <KEY_NAME> --file ~/.ssh/my_rigbox_key.pub
```

<Tip>
  You can register multiple SSH keys for different machines - for example, one for your laptop and one for your desktop. Give each a descriptive name so you can identify them later.
</Tip>

***

## Sync Keys to a Workspace

When you create a workspace, your registered SSH keys are typically synced automatically. If you add a new key while a workspace is already running, sync it manually:

```bash theme={null}
rig ssh sync --workspace <WORKSPACE_ID>
```

This copies all your registered public keys into the workspace VM's `~/.ssh/authorized_keys` file.

<Note>
  Keys are synced automatically on workspace start for most templates. You only need to run `rig ssh sync` if you add a key to an already-running workspace.
</Note>

***

## Connect to a Workspace

When you create a workspace, Rigbox gives you an SSH command in this format:

```bash theme={null}
ssh <WORKSPACE_NAME>-<WORKSPACE_ID_SUFFIX>@<REGION>.rigbox.dev
```

To print the exact SSH target for a workspace at any time, run:

```bash theme={null}
rig workspace ssh-info --workspace <WORKSPACE_ID>
```

`<WORKSPACE_ID_SUFFIX>` is the workspace ID with the leading `ws-` stripped, and `<REGION>` is the workspace's region (for example, `eu-west-1`).

For example, if your workspace is named `my-project` with ID `ws-ctbxi8lb` in the `eu-west-1` region:

```bash theme={null}
ssh my-project-ctbxi8lb@eu-west-1.rigbox.dev
```

The examples below continue with `my-project` / `ws-ctbxi8lb` / `eu-west-1`. Replace those with your own workspace name, ID suffix, and region.

The SSH server identifies you by your registered key and routes the connection directly to your workspace VM.

<Tip>
  The SSH command is shown in the dashboard when you create a workspace. You can also construct it from the workspace name, ID (strip the `ws-` prefix), and region.
</Tip>

### Connecting to the right region

Each workspace runs on a compute node in a specific region (today: `eu-west-1`), and you connect to that region's hostname directly:

```bash theme={null}
ssh my-project-ctbxi8lb@eu-west-1.rigbox.dev
```

The dashboard always shows the correct region in the SSH command it generates, and `rig ssh-info <workspace>` from the CLI prints the same target. As Rigbox expands to more regions, the hostname will change accordingly — there is no central `rigbox.dev:22` gateway to fall back on.

<Note>
  Older `ssh <name>+rig@rigbox.dev` instructions referred to a gateway router that is no longer deployed. If a third-party guide or older script still uses that format, replace it with the region-direct hostname.
</Note>

### Specify an identity file

If your key is not in the default location, specify it explicitly:

```bash theme={null}
ssh -i ~/.ssh/my_rigbox_key my-project-ctbxi8lb@eu-west-1.rigbox.dev
```

### SSH config shortcut

Add this to your `~/.ssh/config` for easier access:

```ssh-config theme={null}
Host my-project
  HostName eu-west-1.rigbox.dev
  User my-project-ctbxi8lb
  IdentityFile ~/.ssh/id_ed25519
```

Then connect with:

```bash theme={null}
ssh my-project
```

***

## File Transfer

Use `scp` to transfer files between your local machine and a workspace.

### Upload a file

```bash theme={null}
scp ./local-file.txt my-project-ctbxi8lb@eu-west-1.rigbox.dev:/home/developer/
```

### Download a file

```bash theme={null}
scp my-project-ctbxi8lb@eu-west-1.rigbox.dev:/home/developer/output.txt ./
```

### Upload a directory

```bash theme={null}
scp -r ./my-project my-project-ctbxi8lb@eu-west-1.rigbox.dev:/home/developer/
```

### Using rsync

For larger transfers or syncing directories, `rsync` is more efficient:

```bash theme={null}
rsync -avz ./my-project/ my-project-ctbxi8lb@eu-west-1.rigbox.dev:/home/developer/my-project/
```

***

## Managing SSH Keys

### List your registered keys

```bash theme={null}
rig ssh ls
```

### List keys synced to a workspace

```bash theme={null}
rig ssh ls --workspace <WORKSPACE_ID>
```

This returns the keys currently in the workspace's `authorized_keys` file.

### Remove a key

```bash theme={null}
rig ssh rm --name <KEY_NAME>
```

<Warning>
  Removing a key with the CLI does not immediately remove it from running workspaces. The key will be removed the next time the workspace restarts or you run `rig ssh sync`.
</Warning>

***

## Troubleshooting

### Connection refused

If you get `Connection refused`, verify:

1. Your workspace is running (check with `rig workspace ls`)
2. Your SSH key is registered and synced
3. You're using the correct username format: `<WORKSPACE_NAME>-<WORKSPACE_ID_SUFFIX>@<REGION>.rigbox.dev`

### Permission denied

If you get `Permission denied (publickey)`:

1. Check that your key is registered: `rig ssh ls`
2. Sync keys to the workspace: `rig ssh sync --workspace <WORKSPACE_ID>`
3. Verify you are using the correct identity file: `ssh -v my-project-ctbxi8lb@{region}.rigbox.dev`

### Slow connection

If connections feel slow:

1. Check your network connection
2. Try connecting with `-o ServerAliveInterval=60` to prevent timeouts
3. For file transfers, prefer `rsync` over `scp` for large datasets

***

## API Reference

* [Add SSH Key](/api-reference/ssh-keys/add) - Register a new SSH key
* [List SSH Keys](/api-reference/ssh-keys/list) - List registered SSH keys
* [Delete SSH Key](/api-reference/ssh-keys/delete) - Remove an SSH key
* [Sync Workspace SSH Keys](/api-reference/ssh-keys/sync-workspace) - Sync keys to a workspace
* [List Workspace SSH Keys](/api-reference/ssh-keys/list-workspace) - List keys on a workspace
