# Installing a key on a server

> Install key puts a keychain key's public half into ~/.ssh/authorized_keys on a cluster for you: one sign-in with your password, a backup, and a test.

Source: https://hiveboard.dev/docs/keys/install-a-key · Section: Keys and sign-in · HiveBoard 0.1.7 · Updated 2026-10-19

## In short

- Install key signs in once with your password (and a code, if the server asks), adds the key's public half to ~/.ssh/authorized_keys only if it is not there yet, and then signs in with the key to prove it works.
- If that file already has something in it, HiveBoard first copies it to authorized_keys.bak followed by the date and time.
- Your password is used for that one sign-in and not stored. This is the only change HiveBoard makes on a server outside job control.

A key signs you in only once its public half is listed in `~/.ssh/authorized_keys` on the
server. **Install key** puts it there for you — the job `ssh-copy-id` does in a terminal — using
your password once. After that, a server set to sign in with that key no longer needs your
password — and if the key has no passphrase and the server asks no code, it connects by itself.

## What happens on the server

1. HiveBoard signs in with your password, and the one-time code if the server asks for one. The
   server's [identity is checked](/docs/connections/server-identity) first, as on every
   connection.
2. It makes sure `~/.ssh` exists.
3. If the key is already in `~/.ssh/authorized_keys`, it stops there and says so.
4. If the file has anything in it, it copies the file to `~/.ssh/authorized_keys.bak.` followed
   by the date and time, such as `authorized_keys.bak.20261019-143005`.
5. It adds one line to the file: the key's public half.
6. It signs in again with the key alone, to prove that it works.

Nothing else on the server is changed, and the private key never leaves your computer. Your
password goes to the server for that one sign-in and is then discarded. The install is noted in
the connection log with the key's fingerprint and name — never with the password.

## While adding a server

On the **Sign-in** step of **Add a server**:

1. Choose **SSH key** (or **Key + code**).
2. Under **Key**, keep **Create a new key for this server**, or pick a key from your keychain.
3. Type **Your password on the server** — it is for installing the key — and the **One-time
   code** if the server asks for one.
4. Press **Install key**.

HiveBoard makes the key if it has to (an Ed25519 key, named after the server), then says *Key
installed.* — or *Key already on the server.* — and whether it signed in with it. Then go on with
**Test connection**. If you installed the key some other way already, skip **Install key**.

## For a server you already have

1. Open Connections → **Keychain** and press **Install on a server…** on the key's card. (On a
   server's **Connection** tab, **Install this key on Ember…** opens the same sheet with that
   server chosen.)
2. Choose the **Server**.
3. Type your **Password on that server**.
4. If the server also asks for a code, tick **The server also asks for a one-time code** and type
   the **One-time code**. It is ticked for you when the server signs in with a code.
5. If the key has a passphrase, type it under **Key passphrase**, so that HiveBoard can prove the
   key works afterwards.
6. Press **Install key**.

When it worked, the sheet says *Key installed.* and *HiveBoard signed in with it — it works.*,
and names the backup it kept. If the key worked and the server does not sign in with it yet, it
offers **Sign in to Ember with this key from now on**, which switches the server to that key —
and, for a server that was an alias from `~/.ssh/config`, makes it self-contained at the same
time.

Once your keychain has a key, a server that signs in with a password suggests this on its
**Connection** tab: *Tired of typing it?*, with a link to install a key. On a server that signs
in with a key, **Create a new key** on the same tab makes a key and then opens this sheet for
that server.

## When the server asks for more

Some servers ask something beyond the password and the code: a PIN and then a token, or a new
password when the old one has run out. During an install the question appears in a small window
of its own, in the server's words. It is asked once; closing the window gives the install up and
sends the server nothing in the answer's place. See
[When a server asks more](/docs/connections/server-questions).

## If it does not work

- *But signing in with it failed* — the key was added, but signing in with it did not work; the
  reason follows. Some servers do not take keys at all: **Check server** says which sign-in
  methods a server accepts.
- The key has a passphrase and none was given — it was added, but could not be tried. Type
  the passphrase under **Key passphrase** next time.
- *The server would not take the key* — adding the line failed; the server's own message
  follows.

If the server's sign-in had been refused, press **Try again** on its page once the key is
installed: HiveBoard does not ask a server that refused it again until you do (see
[A refused sign-in](/docs/help/sign-in-refused)).

## Taking a key off again

HiveBoard never removes a line from `authorized_keys`. To take a key off a server, delete its
line there yourself; the backup holds the file as it was before. Deleting a key from the
[keychain](/docs/keys/keychain) does not remove it from servers either — but without its private
half, nobody can use it.

> [!NOTE]
> Apart from job control, adding this one line is the only change HiveBoard ever makes on a
> server, and only when you ask (see
> [What HiveBoard may change on a cluster](/docs/safety/what-hiveboard-may-change)).

## Check yourself

1. What does Install key do with the password you type?
   - Uses it once to sign in and add the key, then discards it ← the answer
   - Keeps it in the keychain beside the key
   - Sends it again whenever the key is refused
   Why: The password is used for the one sign-in that adds the key; it is not stored.

2. Your authorized_keys on Ember already holds the key. What does Install key change there?
   - Nothing — it reports that the key was already installed ← the answer
   - It adds a second copy of the line
   - It replaces the file with a fresh one
   Why: The key is added only if it is absent; otherwise HiveBoard stops and says the key was already there.

## Try it in the app

- Install a keychain key on one of your servers, then run `tail -1 ~/.ssh/authorized_keys` on the cluster and compare the line with what **Copy public key** gives.

## Related

- [The keychain](https://hiveboard.dev/docs/keys/keychain.md)
- [Adding a server](https://hiveboard.dev/docs/connections/add-a-server.md)
- [When a server asks more](https://hiveboard.dev/docs/connections/server-questions.md)
- [What HiveBoard may change on a cluster](https://hiveboard.dev/docs/safety/what-hiveboard-may-change.md)
- [Two-factor clusters](https://hiveboard.dev/docs/keys/two-factor.md)
