SSH user certificates¶
An SSH user certificate lets a person log in to servers that trust the
CA's user key, as the login names (principals) in the certificate.
No authorized_keys to manage.
Before you start: an SSH key¶
BastionXP CA certifies an SSH key you already have; it does not create key
files. Only the public key (.pub) is sent to the CA. The private key
never leaves your machine, and the certificate is written next to it.
This way the certificate works with any key you already use, including keys that cannot be copied into a file: on a hardware security key, in a password manager such as 1Password, or in the macOS Secure Enclave.
Check for an existing key¶
id_ed25519.pub, id_ecdsa.pub or id_rsa.pub will do. If there is one,
skip to Get one.
Create one with ssh-keygen¶
ssh-keygen is part of OpenSSH: installed on Linux and macOS, and on
Windows 10 and later (PowerShell).
$ ssh-keygen -t ed25519 -C "[email protected]"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/alice/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/alice/.ssh/id_ed25519
Your public key has been saved in /home/alice/.ssh/id_ed25519.pub
- Press Enter to accept the default file,
~/.ssh/id_ed25519. - The passphrase encrypts the private key file. Use one: a copied file is then useless without it.
-Cis a comment, usually your email address; it is only a label.
On a YubiKey, Nitrokey or another FIDO2 key, the private key is made on the device and never leaves it (OpenSSH 8.2 or later on the client and the servers):
ssh-keygen -t ed25519-sk -C "[email protected]"
It asks you to touch the key. Some keys support only ECDSA:
ssh-keygen -t ecdsa-sk. BastionXP CA certifies both.
Only where Ed25519 is not accepted, for example by very old servers:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
The files go to C:\Users\<you>\.ssh\id_ed25519 and
id_ed25519.pub; give --key $HOME\.ssh\id_ed25519.pub to BastionXP CA.
The result is two files:
| File | What it is | Share it? |
|---|---|---|
~/.ssh/id_ed25519 |
the private key | Never. Mode 600, yours only. |
~/.ssh/id_ed25519.pub |
the public key | Yes: this is what --key takes. |
With a passphrase: ssh-agent¶
So that ssh does not ask for the passphrase at every login, load the key
into ssh-agent once per session:
Once the certificate exists (id_ed25519-cert.pub next to the key),
ssh-add loads it together with the key. Run it again after each new
certificate, or use bxp ssh --agent.
Or no key file at all¶
makes a new key in memory, gets a certificate for it, and puts both
into ssh-agent, which drops them when the certificate expires. Nothing
is written to disk. See Straight into ssh-agent.
Get one¶
Your browser opens the identity provider. If you are already logged in there, it comes straight back and the window says "Login succeeded". The certificate gets the login names the access rules list for you.
Certificate: /home/alice/.ssh/id_ed25519-cert.pub
Principals: alice
Valid until: 2026-11-16 08:28 UTC
The certificate is written next to the key, as id_ed25519-cert.pub,
where ssh finds it by itself. Only the public key is sent to the CA.
A user certificate is valid for 16 hours by default (--validity, up
to 24 hours). Requesting again replaces the file.
Straight into ssh-agent¶
makes a new key in memory, gets a certificate for it, and gives both to
ssh-agent, which drops them when the certificate expires. Nothing is
written to disk. ssh then uses them like any key in the agent.
With --key ~/.ssh/id_ed25519.pub as well, the certificate file is written
as above, and the private key goes into the agent with it (its passphrase
is asked if it has one).
The agent is found through SSH_AUTH_SOCK.
Principals¶
- With a token, the certificate gets all the names in the token; with a login, all the principals the rules give you.
--principalasks for fewer:bxp ssh --key ... --principal deploy.- The principal must be exactly the login name on the server
(compared case-sensitively). With SSSD on servers joined to AD, that is
often
[email protected]; see Hosts in Active Directory.
The key ID¶
Every certificate has a key ID, which the SSH server writes to its log at
each login. It is <subject>-<token ID>, set by the CA; the requester
cannot change it. The subject says who the token was made for (with a
login, your name). When several people share one login name, give each
token a subject, so the logs still say who logged in:
bxp token --profile ssh-user --name deploy --subject [email protected]
Inspect a certificate:
Server setup: trust the user CA¶
On every SSH server, once:
curl -s --cacert root.crt https://ca.example.com:8443/ssh_user_ca.pub | sudo tee /etc/ssh/ssh_user_ca.pub
echo "TrustedUserCAKeys /etc/ssh/ssh_user_ca.pub" | sudo tee -a /etc/ssh/sshd_config
sudo systemctl reload sshd
The file may hold several keys (during a key rotation it holds two).
Restrict principals per server (optional)¶
By default a certificate's principal must match the account name. To map principals to accounts explicitly:
Revocation¶
SSH servers do not ask the CA about certificates, so revoking a user certificate only stops its renewal. Keep user certificates short-lived, and remove access on servers to lock someone out at once. Removing a person from the access rules, or from their group at the identity provider, stops new certificates at once.