# Connect over SSH

Open a shell in your box from your own terminal or coding tool, after adding your public key on Access.

> For agents: to reach the person's box over SSH, run `ssh <box name or id>@ssh.box.simular.ai` on their computer. Their public key must be added on https://box.simular.ai/access#ssh-keys, and the account must have paid for box (a plan or a top-up). Raw Markdown: https://box.simular.ai/docs/ssh.md

SSH lets the terminal on your computer, or a coding tool that works on a remote machine, open a shell in your box. You get commands, a shell, file copies with `scp` or `sftp`, and port forwards to programs running inside the box.

SSH works once your account has paid for box, with a plan or a top-up.

## 1. Make a key

Skip this if you already have a key in `~/.ssh` (a file ending in `.pub`).

On macOS, Linux, or Windows (PowerShell), run:

```bash
ssh-keygen -t ed25519
```

Press Enter to keep the default file, and set a passphrase if you want one. This makes two files:

- `~/.ssh/id_ed25519`: your private key. It stays on your computer. Never paste it anywhere.
- `~/.ssh/id_ed25519.pub`: your public key. This is the one you add to box.

Print the public key so you can copy it:

```bash
cat ~/.ssh/id_ed25519.pub
```

It is one line that starts with `ssh-ed25519`. Ed25519, ECDSA, security keys and RSA (2,048 bits or more) all work.

## 2. Add it on Access

1. Open [Access → SSH keys](https://box.simular.ai/access#ssh-keys) and choose **Add key**.
2. Paste the whole `.pub` line. The name is optional; left empty, it takes the comment at the end of the line.
3. Choose which boxes the key reaches: **All boxes** (including boxes you make later) or **Only these**.

You can add up to 20 keys, change a key's boxes later, or remove it. A key belongs to one box account.

## 3. Connect

The user name is your box's name, as shown in the app (its id works too):

```bash
ssh main@ssh.box.simular.ai
```

This opens a shell in the box named `main`. The page shows this line for your first box, with a **Copy** button. If the box is asleep, connecting wakes it.

Run one command instead of a shell:

```bash
ssh main@ssh.box.simular.ai 'ls ~'
```

Copy a file:

```bash
scp ./notes.md main@ssh.box.simular.ai:~/notes.md
```

For whole folders, [Copy files](/docs/copy-files) with rsync sends only what changed.

## Stay connected

A connection with no traffic for 5 minutes closes. To keep it open, add this to `~/.ssh/config` on your computer:

```
Host ssh.box.simular.ai
  ServerAliveInterval 60
```

## What it can't do

- Port forwards work one way, from your computer to a program on the box's own `localhost` (`ssh -L 3000:localhost:3000 main@ssh.box.simular.ai`). Reverse forwards (`-R`), SOCKS proxies (`-D`) and agent forwarding (`-A`) are refused.
- Changing a key's boxes or removing it ends open sessions within a minute.

## If it doesn't work

| Message | Fix |
| --- | --- |
| `Permission denied (publickey)` | The key on your computer isn't on Access, or it is on another box account. `ssh-keygen -lf ~/.ssh/id_ed25519.pub` prints its fingerprint; compare it with the Fingerprint column on Access, which leaves out `SHA256:` and shortens the middle (hover for the whole value). If you have several keys, pick one with `-i ~/.ssh/id_ed25519`. |
| `ssh is open to accounts that paid for box` | Choose a plan or top up on [Billing](https://box.simular.ai/billing). A new payment can take a few minutes to reach SSH, so connect again after that. |
| `box: please upgrade this box to use sftp` | `scp` and `sftp` need a newer box system. On the box's Settings tab, choose **Update system**, then try again. |
| `you have no box named …` | The name before `@` isn't one of your boxes. Use the name shown in the app. |
| `this key does not reach box …` | The key is limited to other boxes. Choose **Edit boxes** on Access. |
| `the box went to sleep; connect again to wake it` | Connect again. |
| `too many ssh connections with this key` | Close some sessions and try again. |

Anything else: [Troubleshooting](/docs/troubleshooting).
