Service Accounts Management
The BastionZero product is maintained for existing BastionZero customers only.
Moving forward, we are natively rebuilding BastionZero’s technology as Cloudflare’s Access for Infrastructure service.
Traditional service accounts enable organizations to take advantage of automation, but they come with a host of security concerns: lack of visibility, long-standing credentials, usability, and the threat of compromise.
BastionZero offers a solution to these drawbacks when using service accounts by providing command logs; session recordings; credential rotation; robust policy enforcement, including instant revocation; and a trustless architecture that utilizes two roots-of-trust.
What are BastionZero service accounts and what can they do?
A BastionZero service account is a Google, Azure, or generic service account that integrates with BastionZero by sharing its JSON Web Key Set (JWKS) URL. The headless authentication closely follows the OpenID Connect (OIDC) protocol. The JWKS contains the public key from a public/private key pair that you must generate. You use the private key to sign the service account’s identity and access tokens, and then BastionZero uses the public key within the JWKS URL to validate the service account.
BastionZero service accounts can perform many of the actions a named identity provider (IdP) user or administrator can perform (e.g., shelling into a target, uploading/downloading files from a Linux box, creating policy, and connecting to a Kubernetes cluster).
There are a few exceptions. Service accounts cannot:
Add new service accounts
Enable or disable a service account
Configure targets to recognize themselves or other service accounts
Rotate a service account’s multi-factor authentication (MFA) credentials, including its own
Change the role (user/admin) of other service accounts or users
Enable or disable MFA for users
Remove users from a BastionZero organization
Delete an IdP groups integration from a BastionZero organization
All the above actions must be done from an administrator account tied to a named IdP user.
All service accounts are added as users by default. If you would like a service account to be able to perform actions beyond a “user” role, you must modify its role after creation to be an administrator.
How to set up your BastionZero service account
IMPORTANT: You must be a BastionZero administrator to set up a service account
Requirements: Service accounts require a minimum of zli v. 6.14.0
and bzero v. 7.3.0
Generic Service Account
Create a private/public key pair by using, for example, openSSL:
openssl genrsa -out private.key 2048; openssl pkey -pubout -in private.key > public.pem
Convert the public key to JSON Web Key (JWK) format.
Create a new URL that serves your JWK. This URL must adhere to the following format:
https://<url>/<service-account-username>@<service-account-domain>
, and it MUST be accessible from the public Internet.For example, a Google service account’s URL would look like:
https://www.googleapis.com/service_accounts/v1/jwk/example-sa@sa-domain.iam.gserviceaccount.com
.
Create and securely store a JSON file that will serve as your provider file. This must contain the following information:
client_id
: a unique identifier chosen by you that BastionZero will use to identify your service accountprivate_key_id
: key id (kid) used when you converted your public key to JWK formatprivate_key
: private key created in step 1. Note that because the output from openSSL includes intentional newlines, you will need to convert those to\n
in your JSON provider fileclient_email
: service account email address (although this does not need to be a functioning email address, it must still validate against the following regex:^[a-zA-Z0-9_-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]+$
)jwksURL
: URL created in step 3jwksURLPattern
: structure of your JWKS URL (prefix and suffix). For example, if your JWKS URL werehttps://bastionzero-service-accounts/alice@bastionzero.com
, the pattern would behttps://bastionzero-service-accounts/*bastionzero.com
, wherehttps://bastionzero-service-accounts/
is your prefix andbastionzero.com
is your suffix.Once you have finished the above steps, your provider file should look something like this:
Log in to the ZLI:
zli login
.Create your BastionZero service account:
zli service-account create <provider-file.json>
. The result of this command will be abzeroCreds.json
file that you must securely store because it will be required to access your BastionZero service account.Your BastionZero service account is now added to your BastionZero organization! Next steps may include adding the service account to new or existing policies, modifying the service account’s role to be an administrator, and configuring your existing targets to recognize your service account.
Finally, once you’ve set up policy and configured any existing targets to recognize your service account (or registered a new target), log in and try connecting to a target as your service account:
zli service-account login --providerCreds /path/to/provider-file.json --bzeroCreds /path/to/bzeroCreds.json
, followed by azli connect
command.
Configure your service account on existing targets
When adding a service account, you may need to take two actions on behalf of existing targets:
Upgrade your
bzero
agent to a version (7.3.0+
) that supports BastionZero service accounts.Once the agent is at the minimum supported feature version, configure existing target(s) to recognize the service account as a valid user using:
zli service-account configure -a <service-account-username>@<service-account-domain> -t <target-name(s), delimited with spaces>
to enable the service account on a subset of existing targets, orzli service-account configure -a <service-account-username>@<service-account-domain> --all
to enable the service account on all existing targets This command will add the JWKS URL format to the targets so any future service accounts that use the same JWKS pattern (prefix and suffix) will already be configured and will require no additional action on your end. For example, if your service account email,alice@bastionzero.com
, has a JWKS URL that looks likehttps://bastionzero-service-accounts/alice@bastionzero.com
, future accounts that also usehttps://bastionzero-service-accounts/*@bastionzero.com
will not require further configuration.
This configuration step is not required for any targets registered after your service accounts are created. All new targets will be provided the existing service accounts' jwksUrlPatterns
during registration. Note that if you add another service account using a new jwksUrlPattern
after target registration, you will have to configure the service account using the zli service-account configure
command, as shown above.
Google Cloud Service Account
The Google Cloud Platform (GCP) provides a convenient way of creating the public/private key pair and the JWKS URL, both of which are needed for setting up your BastionZero service account.
Add a new JSON key. GCP will prompt you to save the private key locally to your machine. This will be your provider file, and we strongly suggest saving it in a vault or other secure location.
Follow the remaining instructions in the generic service account setup, starting at step 5.
Azure Service Account
Azure provides a way to create and host the JWKS URL needed to use BastionZero service accounts.
Use this guide provided by Azure to create the
.well-known
OIDC configuration document. When generating the discovery document in step 2, ensure thejwks_uri
satisfies the required pattern for BastionZero service accounts (see generic service account step 3 for full details).For example, your
jwks_uri
may be:https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_STORAGE_CONTAINER}/openid/v1/jwks/az-example-sa@bastionzero.com
. Note thataz-example-sa@bastionzero.com
does not need to be a functioning email address.
Generate your JWKS using the next section in the Azure guide. Verify that you replace the
--name
value in step 3 with the suffix created in step 1 above (i.e.,--name openid/v1/jwks/azure-example-sa@bastionzero.com
).You’ve now created both the private/public key pair and the JWKS URL that serves the public key. Follow the remaining instructions in the generic service account setup starting at step 4. A few things to note:
Your
client_email
will be the address you used above in step 1 (i.e.,az-example-sa@bastionzero.com
)You will find your key ID in the
jwks.json
file you created in step 2When adding your private key to your BastionZero provider file, make sure that new lines in your key are represented with a valid JSON format (
\n
).
Working with service accounts
BastionZero service accounts are primarily managed from the Zero-Trust Command Line Interface (ZLI). Full details on new and expanded ZLI commands are below.
From the ZLI
From the web app
Although managing your service accounts is done from the ZLI, several changes are present in the web app, as illustrated below.
Policy
You will notice a new field called “Service Accounts” in the Kubernetes, proxy, session recording, and target connect policies. This field allows you to add a service account as a policy subject and grants it access to specific targets and actions.
Audit logs
Service accounts generate audit logs in the same way as BastionZero users tied to an IdP account. Below is an example of the thanos-sa-test@thanos-sa-test
service account performing the "exit" command “ as the ssm-user
on the than-bzero-agent
. Service account activity is captured in command logs, Kubernetes command logs, connections, connections events, and subject events (renamed from user events).
Users & service accounts menu
What used to be called “User Management” underneath the “Administration” section has been renamed to “Users & Service Accounts.” You can both disable/enable a service account from this menu and close all its active connections.
Last updated