Skip to content

Creating tokens

bxp token creates a token. It works in two places.

On the CA machine

Where the configuration file is, it makes the token itself, with token.key:

$ bxp token --config /etc/bastionxp-ca/bastionxp-ca.yaml --profile tls-server --name web.example.com
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...

It prints only the token, so it can be captured in scripts:

TOKEN=$(bxp token --config /etc/bastionxp-ca/bastionxp-ca.yaml --profile tls-server --name web.example.com)

With encrypted keys, it needs the keys' passphrase the same way the server does (see Protect the CA keys). Run it as the CA's user.

From an admin's machine

Anywhere else (where there is no CA configuration file), or with --ca-url, it asks the CA server for a token after a login. You must be an admin in the access rules:

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

Your browser opens for the login.

bxp token --ldap --profile tls-server --name web.example.com --valid-for 1h

Run bxp trust first. The CA's log records who created each token (token created).

Flags

Flag Default Meaning
--profile tls-server tls-server, tls-client, ssh-user, ssh-host, or one of your profiles.
--name A name the certificate may contain (repeat for more). TLS: DNS name, IP address or email address. SSH: login name (ssh-user) or host name (ssh-host).
--subject the first name Who the token is for, e.g. [email protected]. Written to the CA's log and, for SSH, to the SSH server's log at each login.
--valid-for 10m How long the token can be used, at most 24h.
--ca-url, --root saved trust Ask this CA server (remote mode).
--ldap, --ldap-user, --password-stdin Log in with a directory password instead of the browser (remote mode).

Examples

# A web server certificate with two names, usable for an hour.
bxp token --profile tls-server --name web.example.com --name www.example.com --valid-for 1h

# A client certificate for a service, for mutual TLS.
bxp token --profile tls-client --name billing.svc.example.com

# An SSH user certificate for a shared login, recording who it is for.
bxp token --profile ssh-user --name deploy --subject [email protected]

# An SSH host certificate.
bxp token --profile ssh-host --name web1.example.com --name web1

# A device, enrolling over SCEP within a day.
bxp token --profile tls-client --name device1.example.com --valid-for 24h

# One of your own profiles.
bxp token --profile device-client --name [email protected]

Handing tokens over

Requester How to deliver
A colleague A private message; the token expires in 10 minutes.
A CI job A masked CI secret or variable, set just before the job (--valid-for long enough for the job to start).
A new VM cloud-init user data, with a short --valid-for.
Configuration management Create the token on the CA machine in the same run that uses it.