# SSH keys

> Generate an ed25519 key, save it in your account settings so New VM offers it, and add more keys to a VM's authorized_keys by hand.

- URL: https://flockvm.com/docs/vms/ssh-keys
- Section: Virtual machines
- Last updated: 2026-11-01

A VM accepts only SSH keys: its users have no password. You give one public key when you create the VM, and you can save keys in your account so the **New VM** form offers them.

## Generate a key

If `~/.ssh/id_ed25519.pub` already exists, skip this step and use it.

**macOS and Linux:**

```bash
ssh-keygen -t ed25519 -C "you@laptop"
cat ~/.ssh/id_ed25519.pub
```

**Windows (PowerShell):**

```text
ssh-keygen -t ed25519 -C "you@laptop"
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub
```

Press `Enter` to accept the default path. Set a passphrase for a key you keep on a laptop.

The `.pub` file holds one line, the public key:

```text
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI… you@laptop
```

That line is what you paste into flockvm. The file without `.pub` is your private key: never paste it anywhere.

## Accepted key formats

flockvm accepts one OpenSSH public key on one line: the key type, the base64 key data, then an optional comment.

| Type                                                                | Accepted             |
| ------------------------------------------------------------------- | -------------------- |
| `ssh-ed25519`                                                       | Yes (recommended)    |
| `ssh-rsa`                                                           | Yes                  |
| `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521` | Yes                  |
| Security keys (`sk-ssh-ed25519@openssh.com`, `sk-ecdsa-…`)          | Not in the dashboard |

The key is checked as you paste it. Common refusals:

| Message                                                                         | What to do                                                                                    |
| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| "That is a private key. Paste the .pub file instead, and keep this one secret." | Open the `.pub` file instead.                                                                 |
| "Paste a single key, on one line."                                              | Paste one key. Add more keys inside the VM afterwards (below).                                |
| "Use an ssh-ed25519, ssh-rsa or ecdsa key (the line from your .pub file)."      | The line does not start with a supported type, or has options such as `command="…"` in front. |
| "This key looks cut off. Copy the whole line."                                  | Copy the full line, it is long.                                                               |
| "The key says ssh-ed25519 but its data is a different type."                    | The type and the data don't match: copy the line again from the file.                         |

## Save a key in your account

Saved keys belong to your user, not to the organization. The **New VM** form lists them in every organization you belong to.

1. **Open account settings**

   Go to [Settings › Account](https://flockvm.com/dashboard/settings/account) and scroll to **SSH keys**.

2. **Paste the public key**

   Paste the line from your `.pub` file in **Public key**. A check mark shows its type and comment once it is valid.

3. **Name it and add it**

   **Name (optional)** defaults to the key's comment, or its type. Click **Add key**.

![The SSH keys section of account settings](https://flockvm.com/docs/screenshots/ssh-keys.webp "Each key shows its type, fingerprint, when it was added and when a VM last used it.")

Each saved key shows its name, type, SHA256 fingerprint (as `ssh-keygen -lf` prints it), "Added …" and "last used …" or "never used". You can save up to 20 keys. Adding a key that is already saved is refused with its existing name.

You can also save a key while you create a VM: paste it in the form and keep **Save this key to my account, for the next VMs** checked.

## Pick a key for a new VM

The **New VM** form lists your saved keys and preselects the one you used last, or the newest one. Pick another, or **Paste another key**. See [Create a VM](https://flockvm.com/docs/vms/create#04-name-and-ssh-key).

The VM gets exactly one key from the form.

## Where the key goes

On the VM's first boot, the guest writes the key to the `authorized_keys` of the image's login user:

| Image                        | File                              | Also in                                                        |
| ---------------------------- | --------------------------------- | -------------------------------------------------------------- |
| Agent (`ubuntu-26.04-agent`) | `/home/user/.ssh/authorized_keys` | `/root/.ssh/authorized_keys`, so you can also log in as `root` |
| Minimal (`ubuntu-26.04`)     | `/root/.ssh/authorized_keys`      | —                                                              |

On the Agent image the two files are separate: a key you add to one does not reach the other.

## Add a key to a running VM

Keys you save later do not reach existing VMs. To let a teammate or a second laptop in, add their public key inside the VM, to the file of the user they log in as:

```bash
ssh agent
echo "ssh-ed25519 AAAAC3Nz… teammate@laptop" >> ~/.ssh/authorized_keys
```

Or from your machine, with `ssh-copy-id` and a key that already works:

```bash
ssh-copy-id -f -i ~/.ssh/teammate.pub -p 22001 user@HOST
```

On a Minimal VM, the user is `root`: `root@HOST`, and the file is `/root/.ssh/authorized_keys`.

The file is read at each login, so the new key works at once. It stays there through pause, resume, stop and start: flockvm writes `authorized_keys` on the first boot, and at a later boot only if the file is missing or empty.

> **Warning: Keep the file valid.** `authorized_keys` must stay owned by its user (`user` or `root`) with mode `600`, in a `700` `.ssh` folder. If you deleted or emptied the file, **Stop** then **Start** the VM: at boot, flockvm puts back the key the VM was created with. If the file still holds keys but none of yours works, log in as the other user if there is one (on the Agent image, `root` or `user`) and fix it; otherwise you cannot get back in: delete the VM and create a new one.

## Remove a key

In **Settings › Account › SSH keys**, click **Remove** next to the key, then **Remove** again to confirm.

> **Info: Removing a key leaves existing VMs alone.** The key disappears from your account and from the **New VM** form. VMs that already have it keep it in their `authorized_keys`. To revoke access to a VM, delete the line inside the VM, from each user's file that has it (on the Agent image, `/home/user` and `/root`):
>
> ```bash
> sed -i '/teammate@laptop/d' ~/.ssh/authorized_keys
> ```

## Next steps

- [Connect over SSH](https://flockvm.com/docs/vms/ssh): `~/.ssh/config`, file copies, port forwarding.
- [Account settings](https://flockvm.com/docs/team/account): Sign-in, sessions and your profile.
