Skip to content

SSH host certificates

An SSH host certificate lets clients verify a server without "The authenticity of host ... can't be established" prompts and without known_hosts entries per server.

Before you start: the host key

The server's host keys already exist: sshd made them when it was installed, in /etc/ssh/ssh_host_*_key (private) and /etc/ssh/ssh_host_*_key.pub (public). BastionXP CA certifies one of them; it does not make host keys. Check:

ls /etc/ssh/ssh_host_*_key.pub

If they are missing (some minimal images), create the standard set:

sudo ssh-keygen -A

Get one

The administrator. The names are the host names clients use:

bxp token --profile ssh-host --name web1.example.com --name web1

On the server, for its existing host key:

sudo bxp ssh --token <token> --key /etc/ssh/ssh_host_ed25519_key.pub

The certificate is written to /etc/ssh/ssh_host_ed25519_key-cert.pub. Host certificates are valid for 30 days by default (up to 90).

Server setup

Tell sshd to present it:

/etc/ssh/sshd_config
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
sudo systemctl reload sshd

Client setup: trust the host CA

Add one line to ~/.ssh/known_hosts (or /etc/ssh/ssh_known_hosts for every user), made of @cert-authority, the host names it applies to, and the content of ssh_host_ca.pub:

@cert-authority *.example.com ecdsa-sha2-nistp256 AAAA...

Or let bxp trust add it:

bxp trust --ca-url https://ca.example.com:8443 --fingerprint <fp> --ssh

Renew it

Host certificates renew with no token, using the host key as the proof. Run it from the hourly timer (a 30-day certificate renews with 10 days left, so daily is enough here, but one timer for all certificates is simpler):

sudo bxp renew --cert /etc/ssh/ssh_host_ed25519_key-cert.pub \
    --key /etc/ssh/ssh_host_ed25519_key --exec "systemctl reload sshd"

The host key stays the same; only the certificate file is replaced. See Renew certificates.

Check it

ssh-keygen -L -f /etc/ssh/ssh_host_ed25519_key-cert.pub
ssh -v web1.example.com 2>&1 | grep -i "host certificate"