Skip to content

SSH certificates

bxp-cli ssh asks the CA for an SSH certificate. It writes the certificate next to the key, in the place where OpenSSH looks for it:

~/.ssh/id_rsa.pub   ->   ~/.ssh/id_rsa-cert.pub

You can give your own key with --key. Then bxp-cli sends only the public key to the CA, and the private key stays where it is. If you do not give --key, bxp-cli creates a new key in ~/.bxp-cli.

The CA signs RSA keys only, of 2048 bits or more. If you have no RSA key, create one with ssh-keygen -t rsa -b 4096.

bxp-cli does not open SSH connections. To log in to a server, use ssh as usual. ssh finds the certificate by itself, because it is next to the key.

Run bxp-cli trust before you use bxp-cli ssh.

A user certificate

To get a certificate for yourself, run bxp-cli ssh. Your browser opens, and you log in with your company's SSO account.

The certificate lists the login names that you may use on servers. These are called its principals. The CA chooses them from your roles.

$ bxp-cli ssh --key ~/.ssh/id_rsa.pub
Log in in your browser. If it does not open, go to:
  http://127.0.0.1:53817/login
Certificate:  /home/bob/.ssh/id_rsa-cert.pub
Principals:   bob, admin
Valid until:  2026-11-19 22:37 UTC
Roles:        admins
Host CA key:  /home/bob/.bxp-cli/ssh_host_ca-cert.pub

Then log in to a server as usual:

If you did not give --key, the new key is in ~/.bxp-cli. ssh does not look there by itself, so give the key to ssh with -i:

$ bxp-cli ssh
...
Certificate:  /home/bob/.bxp-cli/ssh_user-cert.pub
Private key:  /home/bob/.bxp-cli/ssh_user
...
$ ssh -i ~/.bxp-cli/ssh_user [email protected]

User certificates are valid for a short time: 8 hours by default. When your certificate expires, run bxp-cli ssh again. The new certificate replaces the old file.

The browser login works only if the authority has an OIDC verifier for your SSO provider. See OIDC SSO.

Instead of logging in, you can give a one-time token with the purpose USER-CERTIFICATE. An admin creates it in the web portal with Create Token:

bxp-cli ssh --token $TOKEN

A host certificate

A host certificate lets SSH clients check that they connect to the real server. To get one, you need two things:

  • A one-time token with the purpose HOST-CERTIFICATE. A BastionXP administrator creates it in the web portal: they open the authority in Authority Manager, and choose Create token under One-time tokens. The token is valid for 10 minutes.
  • The host's name, which you give with --principal.

Run bxp-cli ssh as root, and give it the host's own SSH public key:

$ sudo bxp-cli ssh --token $TOKEN --key /etc/ssh/ssh_host_rsa_key.pub \
    --principal host1.example.com
Certificate:  /etc/ssh/ssh_host_rsa_key-cert.pub
Principals:   host1.example.com
Valid until:  2027-02-17 14:37 UTC
User CA key:  /root/.bxp-cli/ssh_user_ca.pub

A command run with sudo uses root's ~/.bxp-cli folder, not yours. So run sudo bxp-cli trust ... once before this. See Trust the CA.

The certificate is valid only for the host's name. Another host cannot use it.

Set up the SSH server

The SSH server needs two changes:

  • It presents its host certificate to clients.
  • It accepts user certificates that the CA issued.

First, copy the user CA's public key to /etc/ssh. bxp-cli ssh saved it in root's .bxp-cli folder:

sudo cp /root/.bxp-cli/ssh_user_ca.pub /etc/ssh/ssh_user_ca.pub

Then add these lines to /etc/ssh/sshd_config:

HostKey /etc/ssh/ssh_host_rsa_key
HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
TrustedUserCAKeys /etc/ssh/ssh_user_ca.pub

Then restart the SSH server:

sudo systemctl restart sshd

Users can now log in with their certificates. A user can log in as any of the login names in their certificate, as long as that account exists on the host.

Set up the SSH clients

By default, ssh asks "Are you sure you want to continue connecting?" the first time it connects to a host. To skip that question for hosts with a certificate from the CA, make ssh trust the CA's host key.

bxp-cli ssh saved the host CA's key as ~/.bxp-cli/ssh_host_ca-cert.pub. Add it to ~/.ssh/known_hosts, in an @cert-authority line. The line also says which host names the CA may vouch for. In this example, it is every host in example.com:

echo "@cert-authority *.example.com $(cat ~/.bxp-cli/ssh_host_ca-cert.pub)" >> ~/.ssh/known_hosts

Remove old entries first

Your known_hosts file may already have entries for these hosts, from before they had certificates. Remove them with ssh-keygen -R host1.example.com. Otherwise, ssh may warn that the host key changed, or refuse to connect.

View a certificate

To see what a certificate contains, use ssh-keygen -L:

$ ssh-keygen -L -f ~/.ssh/id_rsa-cert.pub
/home/bob/.ssh/id_rsa-cert.pub:
        Type: [email protected] user certificate
        Public key: RSA-CERT SHA256:VnbiZpskkX1L3hSM+y5SgaLaC80TKirgJUamnPsU2Fo
        Signing CA: RSA SHA256:ujgfJkcV9mkBNVNKIfeAFjP1DSiXi5uZ1OadNhnl6t8 (using rsa-sha2-256)
        Key ID: "[email protected]"
        Serial: 0
        Valid: from 2026-11-19T14:37:11 to 2026-11-19T22:37:11
        Principals:
                bob
                admin
        Critical Options: (none)
        Extensions:
                permit-X11-forwarding
                permit-agent-forwarding
                permit-port-forwarding
                permit-pty
                permit-user-rc

Flags

Flag What it means
--key The path of an SSH public key, for example ~/.ssh/id_rsa.pub. Without it, bxp-cli creates a new key in ~/.bxp-cli.
--principal The host's name, for a host certificate.
--token A one-time token. You can also set it with BXP_CLI_TOKEN. Without a token, you log in in your browser.
--encrypt-key Encrypt the new private key with a passphrase. bxp-cli asks you for the passphrase.
--no-browser Print the login address instead of opening the browser.

If you have not run bxp-cli trust, also give --ca-url, --authority and --root. See Configuration.

Errors

The message says What it means, and what to do
... is a ssh-ed25519 key, but the server only signs RSA keys for SSH (make one with: ssh-keygen -t rsa -b 4096) The CA signs only RSA keys. Give an RSA key with --key, or leave --key out, and bxp-cli creates a new RSA key.
the server issued no SSH certificate: its SSH CA may be turned off This authority does not issue SSH certificates. Ask your administrator which authority to use for SSH.