Client configuration¶
bxp-cli has no configuration file that you need to write by hand.
bxp-cli needs to know three things about the CA: the server's address, the
authority's ID and the root CA's certificate. For each one, it looks in
these places, in this order, and uses the first value it finds:
- the flag given to the command,
- the environment variable,
- the value that
bxp-cli trustsaved in~/.bxp-cli/config.json.
| Setting | Flag | Environment variable | Saved by bxp-cli trust? |
|---|---|---|---|
| The BastionXP server's address | --ca-url |
BXP_CLI_CA_URL |
Yes |
| The certificate authority's ID | --authority |
BXP_CLI_AUTHORITY |
Yes |
| The CA's root certificate | --root |
BXP_CLI_ROOT |
Yes, as ~/.bxp-cli/tls_root_ca.crt |
A one-time token, for bxp-cli tls and bxp-cli ssh |
--token |
BXP_CLI_TOKEN |
No |
After you have run bxp-cli trust, the commands need none of these flags:
If you have not run bxp-cli trust, give them to every command:
bxp-cli tls --ca-url https://ca.example.com --authority my-ca --root ca-root.crt \
--token $TOKEN --name web1.example.com
bxp-cli checks the BastionXP server's HTTPS certificate. It accepts a
certificate that the machine already trusts, or one that the CA's root
issued. So if the server's certificate comes from a public CA, such as
Let's Encrypt, bxp-cli can connect without --root.
Even then, run bxp-cli trust. It saves the CA's root certificate, which you
need to trust the certificates that the CA issues.
Environment variables in scripts and containers¶
Environment variables are handy for automation, where nothing is saved from one run to the next:
export BXP_CLI_CA_URL=https://ca.example.com
export BXP_CLI_AUTHORITY=my-ca
export BXP_CLI_ROOT=/run/secrets/bastionxp-root.crt
export BXP_CLI_TOKEN="$(cat /run/secrets/host-token)"
bxp-cli tls --name "$(hostname -f)" --out-dir /etc/ssl/private
Prefer BXP_CLI_TOKEN to --token in scripts. Other users of the machine can
see a command's flags in the process list, so they could see a token given
with --token. They cannot see the environment variable.
The client folder¶
bxp-cli keeps its files in the .bxp-cli folder in your home directory. To use
another folder, set BXP_CLI_DIR. This is useful, for example, to keep a
service's certificates apart from a person's:
Each user has their own folder. A command run with sudo runs as root, and
uses root's folder, which is /root/.bxp-cli on most systems. So if you run
bxp-cli commands with sudo, run sudo bxp-cli trust ... once too.
These are the files in the folder:
| File | What it is |
|---|---|
config.json |
The CA's address and the authority's ID. |
tls_root_ca.crt |
The CA's root certificate. |
ssh_user, ssh_user-cert.pub, ssh_host, ssh_host-cert.pub |
Keys that bxp-cli ssh made because you did not give --key, and their certificates. |
ssh_host_ca-cert.pub, ssh_user_ca.pub |
The SSH CAs, for OpenSSH. See SSH certificates. |
host_ids.json |
The ID that the CA gave each host name. |
acme/, scep/ |
The folders that bxp-cli acme and bxp-cli scep use by default. |
bastionxp.log |
The client's log. Look here first when something fails. |