# SSH

Add an organization SSH key, then log in to a VM with ssh, scp and rsync from your laptop.

Source: https://slashinfra.com/docs/platform/ssh
Last modified: 2026-11-30T16:36:19.000Z

Log in to a VM from your laptop with `ssh`, `scp` and `rsync`. Your VM accepts the public keys of your organization, and password login is off.

## Add an SSH key

A key is one public key line from a `.pub` file, and it belongs to the organization, not a project. Ed25519 and ECDSA keys, their security-key forms, and RSA keys of at least 2048 bits are accepted. The name is optional; without one, the key’s comment is the name, else its type.

### Dashboard

- Open [SSH keys](https://app.slashinfra.com/svms/ssh-keys). 
- Select Add SSH key. 
- Paste the contents of a `.pub` file, such as `~/.ssh/id_ed25519.pub`, into Public key. 
- Enter `laptop` in Name. 
- Select Add SSH key. The dashboard says `SSH key added`.

### CLI

```bash
si org ssh-key add ~/.ssh/id_ed25519.pub --name laptop
```

Output

```text
added laptop SHA256:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU
```

### curl

```bash
curl -sS -X POST "https://api.slashinfra.com/ssh-keys" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d "{\"public_key\":\"$(cat ~/.ssh/id_ed25519.pub)\",\"name\":\"laptop\"}"
```

Output

```text
{"id":"k5x2m8q1z0","name":"laptop","type":"ssh-ed25519","fingerprint":"SHA256:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU","public_key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl","added_by":"ada@example.com","created_ms":1795960241240}
```

### Python

```python
import os, requests

with open(os.path.expanduser("~/.ssh/id_ed25519.pub")) as f:
public_key = f.read().strip()

res = requests.post(
"https://api.slashinfra.com/ssh-keys",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"public_key": public_key, "name": "laptop"},
)
res.raise_for_status()
print(res.json()["id"])
```

Output

```text
k5x2m8q1z0
```

### TypeScript

```ts
import { readFileSync } from 'node:fs'

const publicKey = readFileSync(`${process.env.HOME}/.ssh/id_ed25519.pub`, 'utf8').trim()
const res = await fetch('https://api.slashinfra.com/ssh-keys', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ public_key: publicKey, name: 'laptop' }),
})
if (!res.ok) throw new Error(await res.text())
const key = (await res.json()) as { id: string }
console.log(key.id)
```

Output

```text
k5x2m8q1z0
```

A new VM gets every key of the organization at its first start. The guest writes them once to `~/.ssh/authorized_keys`. After that the file is the VM’s; the API and the node do not change it again. A VM that started before you added the key gets nothing, so append the line on that VM:

```bash
OLD_VM=7a2b3c4d5e
si exec $OLD_VM -c 'mkdir -p -m 700 ~/.ssh && cat >> ~/.ssh/authorized_keys >/dev/null && echo appended' < ~/.ssh/id_ed25519.pub
```

Output

```text
appended
```

## List SSH keys

List returns every key of the organization, oldest first. Each key has a name, type, fingerprint, who added it and when. The API returns `[]` when the organization has no keys.

### Dashboard

- Open [SSH keys](https://app.slashinfra.com/svms/ssh-keys). 
- The table lists every key with Name, Fingerprint and Added. The type and who added it appear under the name.

### CLI

```bash
si org ssh-key ls
```

Output

```text
name    type         fingerprint                                         added by          added
laptop  ssh-ed25519  SHA256:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU  ada@example.com   2026-11-29 13:51:00Z
```

### curl

```bash
curl -sS "https://api.slashinfra.com/ssh-keys" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
[{"id":"k5x2m8q1z0","name":"laptop","type":"ssh-ed25519","fingerprint":"SHA256:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU","public_key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl","added_by":"ada@example.com","created_ms":1795960241240}]
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/ssh-keys",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
for key in res.json():
print(key["id"], key["name"], key["type"])
```

Output

```text
k5x2m8q1z0 laptop ssh-ed25519
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/ssh-keys', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const keys = (await res.json()) as { id: string; name: string; type: string }[]
for (const key of keys) console.log(key.id, key.name, key.type)
```

Output

```text
k5x2m8q1z0 laptop ssh-ed25519
```

## Connect to a VM

Port 22 is served by the default image; a VM of the `postgres` image has no SSH server. A stopped VM starts on its first connection.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select your VM. 
- Select Overview. 
- Under SSH, copy the Forward the port command and run it in a terminal on your laptop. Keep that terminal open. 
- Copy the Connect command and run it in a second terminal.

With `devbox`, the commands are `si port forward devbox 22:2222` and `ssh -p 2222 user@127.0.0.1`.

### CLI

Create `devbox` with the default image:

```bash
si create --name devbox
```

Output

```text
6f1c0f0e8a
```

Set `VM` to the id in the answer, then add this block to `~/.ssh/config` once. It sends every `*.slashinfra.dev` host through `si port forward --stdio`:

```text
Host *.slashinfra.dev
User user
ProxyCommand si port forward --stdio %h 22
```

Log in as your VM’s user, `user`:

```bash
VM=6f1c0f0e8a
ssh user@$VM.slashinfra.dev whoami
```

Output

```text
user
```

An open SSH session keeps the VM awake, so close it when you are done. `scp` and `rsync` work with the same host name.

## Delete an SSH key

Delete stops new VMs from getting the key. Existing VMs that have it keep it in their own `~/.ssh/authorized_keys`, so remove the line there as well. The API names the key by its id; `si org ssh-key rm` also takes its fingerprint or name. `devbox` keeps it until you delete the VM.

### Dashboard

- Open [SSH keys](https://app.slashinfra.com/svms/ssh-keys). 
- Select More actions on `laptop`. 
- Select Delete. The dashboard removes the key after five seconds; select Undo to keep it.

### CLI

```bash
si org ssh-key rm laptop
```

Output

```text
deleted laptop
```

### curl

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/ssh-keys/k5x2m8q1z0" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/2 204
...
```

### Python

```python
import os, requests

res = requests.delete(
"https://api.slashinfra.com/ssh-keys/k5x2m8q1z0",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

Output

```text
204
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/ssh-keys/k5x2m8q1z0', {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
console.log(res.status)
```

Output

```text
204
```

```bash
si rm devbox
```

Output

```text
deleted 6f1c0f0e8a
```

## Options

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `public_key` | string | Required | One `<type> <base64> [comment]` line; Ed25519, ECDSA, their security-key forms, or RSA of at least 2048 bits | The key that new VMs accept. | 
| `name` (`--name`) | string | The key comment, else its type | 1 to 100 characters, no line break | The name that lists show and `si org ssh-key rm` accepts. | 
| `id` (path, `<KEY>` in the CLI) | string | Required | A key id from the list; the CLI also takes its `SHA256:` fingerprint or name | The key that delete removes. |

## Errors

| Code | When | Fix |
| --- | --- | --- |   
| [`invalid_ssh_key`](https://slashinfra.com/docs/reference/errors#invalid_ssh_key) | Add sends text that is not one public key line. | Send one line from a `.pub` file. | 
| [`private_key`](https://slashinfra.com/docs/reference/errors#private_key) | Add sends the private half of a key. | Send the `.pub` file, and replace the private key if you shared it. | 
| [`unsupported_key_type`](https://slashinfra.com/docs/reference/errors#unsupported_key_type) | Add sends DSA or another unsupported type. | Use Ed25519, ECDSA, a security key, or RSA of at least 2048 bits. | 
| [`rsa_key_too_short`](https://slashinfra.com/docs/reference/errors#rsa_key_too_short) | Add sends an RSA key below 2048 bits. | Create an Ed25519 key, or an RSA key of at least 2048 bits. | 
| [`invalid_name`](https://slashinfra.com/docs/reference/errors#invalid_name) | Add sends a name with a line break. | Send the name on one line. | 
| [`key_exists`](https://slashinfra.com/docs/reference/errors#key_exists) | Add sends a key the organization already has. | Use the existing key, or delete it first. | 
| [`ssh_key_limit`](https://slashinfra.com/docs/reference/errors#ssh_key_limit) | Add would make the 51st key. | Delete a key, or ask about your plan. | 
| [`ssh_key_not_found`](https://slashinfra.com/docs/reference/errors#ssh_key_not_found) | Delete names no key of the organization. | List the keys and use the id. | 
| [`not_supported_by_image`](https://slashinfra.com/docs/reference/errors#not_supported_by_image) | A port 22 request names a VM of an image without SSH, such as `postgres`. | Use a VM of the default image. |

Errors that any request can return are in the [error catalog](https://slashinfra.com/docs/reference/errors).

## Permissions

| Operation | Who can | Key action |
| --- | --- | --- |   
| Add an SSH key | Any member | `svm:write` | 
| List SSH keys | Any member | `svm:read` | 
| Delete an SSH key | Any member | `svm:write` | 
| Connect to a VM | Any member | None |

## Limits

- An organization holds 50 keys. The 51st add answers 409 `ssh_key_limit`. 
- A key name has 1 to 100 characters and no line break. 
- Ed25519 and ECDSA keys, their security-key forms, and RSA keys of at least 2048 bits are accepted. DSA is not. 
- Port 22 is served by the default image only. A VM of the `postgres` image has no SSH server. 
- A VM gets the organization’s keys once, at its first start. A key added later adds no line to an existing VM. 
- Deleting a key leaves one line in the `authorized_keys` of every VM that already has it; remove it there as well.

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [VMs](https://slashinfra.com/docs/platform/vms): create, start and delete the VM you log in to. 
- [Private network](https://slashinfra.com/docs/platform/private-network): reach a VM by name from your other VMs and your tailnet. 
- [Sleep and wake](https://slashinfra.com/docs/how/sleep-and-wake): keep a VM reachable with the `on` policy.
