Search
⌃K
Links

Installing the Agent

BastionZero's agent, bzero, secures access to your target through MrTAP and centralized policy.
Agent installation has 2 parts:
  1. 1.
    ​Install the bzero agent on your target using one of the methods below.
  2. 2.
    ​Register the agent with BastionZero.

Step 1: Agent installation

BastionZero's agent, bzero, is compatible with x86 and amd64 platforms. It is available through apt and yum package managers, a Bash script, a guided zli Quickstart, Ansible playbook, and via helm and yaml for Kubernetes.

Install using Yum

  1. 1.
    Use the yum-config-manager to add the BastionZero repo.
    sudo yum-config-manager --add-repo https://download-yum.bastionzero.com/bastionzero.repo
  2. 2.
    Install the agent bzero.
    sudo yum install -y bzero
  3. 3.
    Fast forward to agent registration | Register the agent with BastionZero. See the full list of bzero arguments below. The agent must be run as root.
    sudo bzero -registrationKey *registration API key secret*

Registration keys are the only secret needed for use with BastionZero.

They are multi-use (you do not need to create a new key for every target registered) and should be stored in a secure place, such as a vault. Learn more about the role registration keys play in BastionZero here.
For more detailed information regarding how to generate or retrieve your secret and what other flags are available with the registration command, take a look at our registration overview.

Install using Apt

  1. 1.
    Install the BastionZero public key from the Ubuntu key-server.
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E5C358E613982017
  2. 2.
    For https, add the BastionZero repo with:
    sudo add-apt-repository 'deb https://download-apt.bastionzero.com/production/apt-repo stable main'
  3. 3.
    For http (i.e., on an Ubuntu 14.x machine), add the BastionZero repo with:
    sudo add-apt-repository 'deb http://download-apt.bastionzero.com/production/apt-repo stable main'
  4. 4.
    Update the apt cache.
    sudo apt update
  5. 5.
    Install the agent bzero.
    sudo apt install -y bzero
  6. 6.
    Fast forward to agent registration | Register the agent with BastionZero. See the full list of bzero arguments below.
    sudo bzero -registrationKey *registration API key secret*

Registration keys are the only secret needed for use with BastionZero.

They are multi-use (you do not need to create a new key for every target registered) and should be stored in a secure place, such as a vault. Learn more about the role registration keys play in BastionZero here.
For more detailed information regarding how to generate or retrieve your secret and what other flags are available with the registration command, take a look at our registration overview.

Install using Helm

  1. 1.
    Add the BastionZero Helm repo.
    helm repo add bastionzero https://bastionzero.github.io/charts/
  2. 2.
    Install the Helm chart. This will install and register the bzero agent in your cluster. Refer to the tables below for a complete list of Helm arguments. The command below is a base for you to expand on as desired.
    helm install bctl-agent bastionzero/bctl-quickstart --set apiKey=$REGISTRATION_SECRET --set clusterName=example-helm-cluster --namespace=bastionzero --create-namespace
  3. 3.
    Now that your agent is registered
    🎉
    , update your Kubernetes policy to configure which SSO users have access to your cluster.

Registration keys are the only secret needed for use with BastionZero.

They are multi-use (you do not need to create a new key for every target registered) and should be stored in a secure place, such as a vault. Learn more about the role registration keys play in BastionZero here.
For more detailed information regarding how to generate or retrieve your secret and what other flags are available with the registration command, take a look at our registration overview.
Helm does not automatically update the Helm chart when there are new changes. Check our latest release to stay up to date.
Run helm repo update bastionzero to update to the latest chart version.

Helm installation flags

Flag
Description
apiKey
(required) The secret of your BastionZero registration key.
clusterName
(required) The name your cluster will appear as in BastionZero.
image.agentImageTag
(optional, but STRONGLY recommended) The specific version of the BastionZero agent to be downloaded using Helm. Refer to docker to find the most recent version.
If not specified, latest will be used as the default.
namespace
(optional, but STRONGLY recommended) The namespace you would like to add your cluster into. If omitted, the agent will be installed in the default namespace, which is not recommended.
create-namespace
(optional) If creating a new namespace, this argument must be included as --create-namespace.
agentResources.limits.cpu
(optional) Limits the amount of CPU resources the agent installation can consume.
agentResources.limits.memory
(optional) Limits the amount of memory the agent installation can consume.
agentResources.requests.cpu
(optional) Limits the amount of CPU request resources the agent can consume.
agentResources.requests.memory
(optional) Limits the memory the requests from the agent installation can consume.
quickstartResources.limits.cpu
(optional) Limits the amount of CPU resources the quickstart installation script can consume.
quickstartResources.limits.memory
(optional) Limits the amount of memory the quickstart installation script can consume.
quickstartResources.requests.cpu
(optional) Limits the amount of CPU request resources the quickstart installation script can consume.
quickstartResources.requests.memory
(optional) Limits the memory the requests from the quickstart installation script can consume.
logLevel
(optional) Configure the log level of logs printed by the agent. Valid options include: disabled, trace, debug, info, warn, or error.
Pro tip: To get started faster, consider passing the following parameters to bypass additional policy setup.
Flag
Description
--set "users={SOME_ID_USERS}"
Use a list of comma separated SSO users (i.e., [email protected]) to add users automatically to the auto-generated policy. This will allow you and others permission to connect to your cluster right away.
--set "targetUsers={SOME_KUBE_USERS}"
Use a list of comma separated Kube users to automatically add to your policy. We utilize the impersonation API to give permissions to execute commands remotely. In order to create these users, ensure that there is a ClusterRoleBinding or RoleBinding that has a user as a subject. The name of this user is what we'll impersonate.
--set "targetGroups={SOME_KUBE_GROUPS}"
Pass a list of comma separated Kube groups to automatically add to your policy. These groups must already be configured on your cluster.
Best practice with namespaces
The --namespace flag determines which namespace to install the BastionZero agent in. If the namespace already exists, omit the --create-namespace flag.
If you don't use the --namespace flag, then the agent will be installed in the default namespace, which is not recommended.
Best practice with image tag
By default**,** our Helm chart will use the tag latest for the agent. We strongly recommend that you override that using the flag:
--set "image.agentImageTag=x.x.x"
to specify the agent version explicitly. See docker for the most recent version.

How to upgrade using Helm

If you set the image.agentImageTag when installing via Helm, then you can use helm upgrade to update this value and upgrade the agent to a newer version:
helm upgrade bctl-agent bastionzero/bctl-quickstart --reuse-values -n bastionzero --set "image.agentImageTag=x.x.x"
If image.agentImageTag was not specified during installation, then the agent pod is running with an image of version latest. You can use kubectl rollout to upgrade the agent to the latest version:
kubectl rollout restart deployment bctl-<clusterName>-agent -n bastionzero
where <clusterName> is replaced with the value you specified for clusterName during installation (e.g. example-helm-cluster if using examples above).
The example commands above assume the agent was installed in the bastionzero namespace. Please change accordingly if you installed the agent in a different namespace.

Security recommendation

When using the --set apiKey flag, the provided BastionZero registration key is stored as an unmasked environment variable in the pod spec. Users with Kubernetes RBAC permission to list pods or deployments can see the contents of this value. In addition, users with RBAC access to view Helm installation history can see this value stored.
Therefore, it is recommended to store the registration key as a Kubernetes secret and to follow best practices on protecting this Kubernetes secret as outlined here. For example, you should limit RBAC access to view this secret and prevent others from creating pods or deployments in the namespace you install the agent in.
Once the secret is created, you can install the agent and set the apiKeyExistingSecret value to the name of the secret instead of using --set apiKey. Please ensure the registration key is stored in secret.data['api-key']. Our Terraform example below shows how to install the agent using the apiKeyExistingSecret flag.

Example Terraform

Below is example Terraform you can use to install the agent via Helm.
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = "2.9.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.18.0"
}
}
}
​
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
config_context = "your-kube-ctx"
}
}
​
provider "kubernetes" {
config_path = "~/.kube/config"
config_context = "your-kube-ctx"
}
​
variable "registration_key" {
type = string
description = "Registration key"
nullable = false
sensitive = true
}
​
variable "agent_version" {
type = string
description = "Agent version to install"
nullable = false
}
​
resource "kubernetes_namespace" "bastionzero_namespace" {
metadata {
name = "bastionzero"
}
}
​
resource "kubernetes_secret" "registration_key_secret" {
metadata {
name = "bctl-agent-registration-key"
namespace = kubernetes_namespace.bastionzero_namespace.metadata[0].name
}
​
data = {
"api-key" = var.registration_key
}
}
​
resource "helm_release" "bctl_agent" {
name = "bctl-agent"
repository = "https://bastionzero.github.io/charts/"
chart = "bctl-quickstart"
# version = Set this if you want to install a specifc version of the chart.
# Otherwise, the latest chart is used.
​
set {
name = "clusterName"
value = "example-helm-cluster"
}
​
set {
name = "apiKeyExistingSecret"
value = kubernetes_secret.registration_key_secret.metadata[0].name
}
​
set {
name = "image.agentImageTag"
value = var.agent_version
}
​
reuse_values = true
​
namespace = kubernetes_namespace.bastionzero_namespace.metadata[0].name
}

Install using YAML

  1. 1.
    Generate your YAML file, where clusterName is the name of your cluster. This command will generate a Kubernetes YAML with a Service Account, RBAC permissions/bindings, secret, and deployment.
    zli generate kubeYaml {clusterName}
  2. 2.
    Apply the YAML. Your existing Kubernetes credentials are used to apply the YAML and create BastionZero's agent in the cluster.
    kubectl apply -f {someFile}
  3. 3.
    Now that your agent is registered, update your Kubernetes policy to configure which SSO users have access to your cluster. If you intend to access the cluster yourself, you will also want to update your kubeconfig so you can connect through BastionZero.
Pro tip
To pipe the output to a file directly, use:
zli generate kubeYaml {clusterName} --outputFile {someFile}
where someFile is the name of your YAML file.
Important
This YAML file will only be valid for 10 minutes after creation due to the activation token. If more than 10 minutes has passed, generate the YAML file again.

Install using Bash

You must be a BastionZero administrator to generate the Bash script.
  1. 1.
    Log in to the BastionZero web app.
  2. 2.
    Open a new tab or window and navigate to our API specification. This link will open directly to the entry for generating the Bash autodiscovery script.
  3. 3.
    You will see two fields for target name and environment ID, respectively. In the target name field, select one of the four options for how you'd like to name your target: timestamp, DigitalOcean metadata, AWS EC2 metadata, or Bash hostname.
  4. 4.
    To specify which environment to add your target to, switch to the window containing the BastionZero web app. Navigate to the environments tab. Click the box in the top left corner that reads "Display: UUID." Copy the corresponding environment UUID from the web app into the environment ID field in the API specification.
    • For simplicity, we recommend choosing the Default environment.
    • If you'd like to create a new environment, you can do so by using the "Create" -> "Environment" option in the top right corner of the web app.
  5. 5.
    Click "Try." You should receive a 200 response and an output starting with "autodiscoveryScript." The value of that key is your Bash script.
  6. 6.
    Use this script in the "User-Data" field when provisioning a new remote host or integrate it with your custom setup.
There is no additional action required to register your agent with BastionZero. It is integrated into the Bash script.

Install using Ansible

You must be a BastionZero administrator to generate the Ansible script.
  1. 1.
    Log in to the BastionZero web app.
  2. 2.
    Open a new tab or window and navigate to our API specification. This link will open directly to the entry for generating the Ansible autodiscovery script.
  3. 3.
    You will see one field for environment ID. To specify which environment to add your target to, switch to the window containing the BastionZero web app. Navigate to the environments tab. Click the box in the top left corner that reads "Display: UUID." Copy the corresponding environment UUID from the web app into the environment ID field in the API specification.
    • For simplicity, we recommend choosing the Default environment.
    • If you'd like to create a new environment, you can do so by using the "Create" -> "Environment" option in the top right corner of the web app.
  4. 4.
    Click "Try." You should receive a 200 response and an output starting with "autodiscoveryScript." The value of that key is your Ansible script.
  5. 5.
    Run this script with your Ansible setup. It will both install and register the bzero agent on your Ansible targets. Note: the BastionZero target names will match the hostnames of the Ansible targets.
There is no additional action required to register your agent with BastionZero. It is integrated into the Ansible script.

Install using ZLI Quickstart

Quickstart takes as little as 3 minutes to secure your target.
  1. 1.
    Launch the 4-step Quickstart process. Quickstart will install and register bzero on the target(s) you specify.
zli quickstart

Step 2: Agent Registration

For non-administrators to perform agent registration, you must have access to the registration key secret, such as through a vault.

Registration keys are the only secret needed for use with BastionZero.

They are multi-use (you do not need to create a new key for every target registered) and should be stored in a secure place, such as a vault. Learn more about the role registration keys play in BastionZero here.
If you do not have an existing secret, instructions on how to generate a registration secret are here.
If you already have a registration secret but are unable to access it, administrators can retrieve the default secret from an autodiscovery script or by using the API. Please contact your BastionZero administrator if this is the case.
Flags that can be specified during registration are listed in the table below. Any number of flags can be specified after bzero.

Bzero flags

Important: the -registrationKey flag is required.
Flag
Description
-registrationKey
(required) The registration secret provisioned using the web app. It is an API key used only for registering new targets. It is formatted as a base64 string.
-environmentId
(optional) The uuid of the environment you want to put the agent in. If environmentId is not provided, the target will be placed in the default environment and can be assigned a new environment via bastionzero.com.
-targetName
(optional) The desired name of the target. If no name is provided, this will default to the target’s host name.
-org
(optional) The unique identifier for your SSO instance. In Google, it’s referred to as orgID. In Microsoft, this is the tenantID. If you are using Okta, no -org is required.
-orgProvider
(optional) Your identity provider, e.g., “Google”, “Microsoft”, “Okta”, etc. If neither the -org nor the -orgProvider are set, the information defaults to values provided by BastionZero during the registration process.
-logLevel
(optional) Sets the log level when running the agent. Allowed values are debug, info, error, and disabled. The default is debug, the most verbose level; info is slightly less verbose. error only covers failure cases, and disabled will silence all logging from the agent.
-y
(optional) If you're attempting to register a new version of the agent on a target that already had an agent installed, use the -y flag to force re-registration and create a new target. The old target will be deactivated. You may need to restart the agent using sudo systemctl restart bzero.

Autodiscovery

BastionZero can autodiscover targets without public IPs, open ports, or VPNs. The BastionZero agent, bzero, will initiate an outbound connection to the BastionZero SaaS from any private or public cloud. In some cases, like an application-based firewall, the administrator may need to allow the BastionZero DNS entry or IP, but that is organization-specific. The only requirement for autodiscovery is that the agent can get out to the Internet.
Diagram of autodiscovery flow in BastionZero
Autodiscovery is initiated by a provisioner. Examples of provisioners may include:
  • Package managers
  • Bash scripts
  • Ansible playbook
  • Helm chart
  • YAML
It is the provisioner's responsibility to use a registration API key's secret to request the one time activation code from BastionZero. The activation code is used by the agent to identify itself to BastionZero as a resource within a specific organization. If an issue arises, bzero agents support error handling and recovery as part of the registration and activation process.
The specific provisioning implementation is described in greater detail below in Installation by Use Case.
Looking for how to connect to your resources instead? See Connecting To Your Resources in the User Guide.

Installation by use case

Remote Servers

To configure your server, you will need to:
The bzero agent can be installed on your remote server in a variety of ways: yum and apt package managers, Bash script, Ansible playbook, or zli Quickstart.
Once the agent is installed on your target, it needs to register with BastionZero. If you've installed it using Bash, Ansible, or zli Quickstart, this process is already completed for you. For package managers, the registration process is detailed under yum and apt.

Bash

The Bash script allows installation of the bzero agent through the zli, during instance launch (i.e., by using the "User-Data" with AWS EC2), a Terraform deployment, or other deployment system.
The Bash script implements the autodiscovery process. Using your organization's default registration secret, or an administrator's registration secret, the script will request an activation token from BastionZero and then phone home to the service with an outbound connection. Registration in this case does not require any additional action from you. See here for more about registration API keys.
The script contains logic to autodiscover the Linux distribution and microarchitecture (x86 or ARM) in order to download and install the appropriate agent. The script also contains error recovery logic in the event the registration does not succeed for any reason. By default, the script will always download and install the latest BastionZero agent.

Ansible

BastionZero supports installing the bzero agent via an Ansible playbook. The Ansible playbook implements the autodiscovery process. Using your organization's default registration secret, or an administrator's registration secret, the playbook will request an activation token from BastionZero and then phone home to the service with an outbound connection. Registration in this case does not require any additional action from you. See here to learn more about generating a registration API key.
The playbook contains logic to autodiscover your Linux distribution and microarchitecture (X86 or ARM) in order to download and install the appropriate agent. By default, the playbook will always download and install the latest BastionZero agent.

Databases

To configure your database target, you will need to:
BastionZero relies on a proxy target in order to make a secure connection to your database. The proxy target must be able to resolve a DNS hostname or reach the IP specified by the database target configuration. No configuration, outside of the proxy target having network access to the database, is required.
This feature utilizes our zli for end users to make connections. When connecting to a database target, traffic destined for the database will use local port forwarding through the zli and the proxy target to make a secure MrZAP connection to the database. Upon requesting a connection, the user is returned a local port number, which is used in the database client configuration. The database username, password, and role continue to be managed independent of BastionZero.

Install and Register the BastionZero Agent

The bzero agent can be installed on your database proxy target in a variety of ways: yum and apt package managers, Bash script, Ansible playbook, or zli Quickstart.
Once the agent is installed on your proxy target, it needs to register with BastionZero. If you've installed it using Bash, Ansible, or zli Quickstart, this process is already completed for you. For package managers, the registration process is detailed under yum and apt.

Accessing Databases Through a Kubernetes Cluster

Database Access Through Kubernetes Architecture
Database support is available on the BastionZero agent v.4.0.0+.
We recommend installing via Helm, and YAML is supported as well. Make sure to complete the Kubernetes setup to ensure the agent is registered with BastionZero.

Configure Your Database Target

Database target configuration is part of the "Create" function on the BastionZero web app, or you can use the API. The "Create" target screen in the web app is shown below:
Add a Database Target
Update the database target fields with the needed context as explained below.
Field
Description
Name
The name of the database target. This is assigned to an environment or used in a policy.
Proxy Target
The name of the target that is the proxy.
Remote Host
The DNS hostname or the IP address of the database target.
Remote Port
The remote port number that the database target is listening on, usually 443 for HTTPS.
Local Host
The localhost that the BastionZero zli will listen on. This should not need modification.
Local Port
The local port number, which the BastionZero zli will use to intercept traffic. If you leave it blank, an open port on the client machine will be selected for the user.
Environment
The environment to which this target should be added.

Add a Database Policy

The database policy will allow a user to connect to the database. For this type of access, BastionZero utilizes a proxy policy. Create a policy using the type proxy and update and save the fields per the descriptions below.
Proxy Policy
Field
Description
Policy Name
The name of your policy.
Description
Information useful for describing the purpose or context of your policy.
Users
A list of identity provider users who will be authorized to use this policy.
Groups
A list of identity provider groups who will be authorized to use this policy.
Resource Type
Either an envrionment or a list of targets which are the resource(s) authorized for access by this policy.

Kubernetes

To secure a Kubernetes cluster with BastionZero, you'll need to:
Users must have access to the cluster being secured (i.e., are able to create new deployments, secrets, and modify RBAC permissions). It is also recommended that the cluster have existing clusterRoles and clusterRoleBindings.
To install the bzero agent, we recommend using Helm. YAML is also supported.
If you're using Helm, you'll need a registration secret to install and register your agent. You can find those instructions here.

Verify the Agent Is Running

Once the agent is installed, ensure it has phoned home by listing your targets using
zli list-targets
You should see a list of any existing targets in addition to your newly added Kubernetes cluster, {clusterName}.
List of targets within a Kubernetes cluster that is secured by BastionZero
You can also check that the agent has been installed using
kubectl get pods -n bastionzero
The output should look similar to the following:
➜ ~ kubectl get pods -n bastionzero
| NAME | READY | STATUS | RESTARTS | AGE |
| ------------------------------------- | ----- | ------ | -------- | --- |
| bzdemo-cluster-agent-7f57c754b9-9qpnq | 1/1 | Running | 0 | 3m12s |

Update Your Kubernetes Policy

Both Helm and YAML agent installation will create an environment and policy for your cluster. It must be updated to grant access to your desired users and target roles.
The auto-created environment and policy take the form "{clusterName}-policy" and "{clusterName}-env" respectively.
  • To update the target users:
    zli policy add-targetuser dev-cluster-policy cluster-admin
    This tells BastionZero that the cluster-admin is an approved Kubernetes user that can access the cluster. Notably, this does not create a Kube policy on the cluster itself for access.
  • To update the target groups:
    zli policy add-targetgroup dev-cluster-policy system:authenticated
    This updates the Kubernetes groups that are allowed to be assumed for this cluster.
  • To update the users:
    zli policy add-user dev-cluster-policy [email protected]
    This updates the SSO users allowed to access the cluster.
Ensure the users, roles, and groups are correct by viewing the updated policy.
zli policy list kubernetes
Example of a Kubernetes policy

Connect to your cluster via BastionZero

Once the agent has been installed in your cluster and you've configured your Kubernetes policy accordingly, you're ready to connect.
zli connect {role}@{clusterName}
See here for more details and helpful tips on connecting to Kubernetes targets.

Webservers

To configure your webserver target, you will need to:
Webserver Architecture
BastionZero relies on a proxy target in order to make a secure connection to your webserver. The proxy target must be able to resolve a DNS hostname or reach the IP specified by the webserver target configuration. No configuration, outside of the proxy target having network access to the webserver, is required.
This feature utilizes the zli for end users to make connections. When connecting to a webserver target, the user's default browser will open a new tab with the connection to the web service. This new connection will utilize a local port via a TCP socket to the BastionZero SaaS. This connection is made through the MrZAP protocol. As a result, BastionZero can authenticate and authorize the access, but it cannot alter any commands sent across.

Install and Register the BastionZero Agent

The bzero agent can be installed on your webserver proxy target in a variety of ways: yum and apt package managers, Bash script, Ansible playbook, or zli Quickstart.
Once the agent is installed on your proxy target, it needs to register with BastionZero. If you've installed it using Bash, Ansible, or zli Quickstart, this process is already completed for you. For package managers, the registration process is detailed under yum and apt.

Accessing Webservers Through a Kubernetes Cluster

Webserver Access Through Kubernetes Architecture
Webserver support is available on the BastionZero agent v.4.0.0+.
We recommend installing via Helm, and YAML is supported as well. Make sure to complete the Kubernetes setup to ensure the agent is registered with BastionZero.

Configure Your Webserver Target

Webserver target configuration is part of the "Create" function on the BastionZero web app, or you can use the API. The "Create" target screen in the web app is shown below:
Add a Web Target
Update the webserver target fields with the needed context as explained below.
Field
Description
Name
The name of the webserver target. This is assigned to an environment or used in a policy.
Proxy Target
The name of the target that is the proxy.
Remote Host
The DNS hostname or the IP address of the webserver target.
Remote Port
The remote port number that the webserver target is listening on, usually 443 for HTTPS.
Local Host
The localhost that the BastionZero zli will listen on. This should not need modification.
Local Port
The local port number, which the BastionZero zli will use to intercept traffic. If you leave it blank, an open port on the client machine will be selected for the user.
Environment
The environment to which this target should be added.

Add a Webserver Policy

The webserver policy will allow a user to connect to the webserver. For this type of access, BastionZero utilizes a proxy policy. Create a policy using the type proxy and update and save the fields per the descriptions below.
Proxy Policy
Field
Description
Policy Name
The name of your policy.
Description
Information useful for describing the purpose or context of your policy.
Users
A list of identity provider users who will be authorized to use this policy.
Groups
A list of identity provider groups who will be authorized to use this policy.
Resource Type
Either an envrionment or a list of targets which are the resource(s) authorized for access by this policy.

Dynamic Access Targets

Dynamic access targets (DATs) are machines discovered by querying a provisioning server that runs outside of BastionZero. The targets are dynamic because given a specific Dynamic Access configuration, the state, and number of targets online are constantly changing. The provisioning server has two main responsibilities:
  1. 1.
    Spin up and register a target. A target can be a server, container, virtual machine (e.g. EC2 instance), etc. The provisioning server can spin these targets up on-demand or have a pool of targets waiting to be registered; the way these machines are created is up to the provisioning server's implementation. The only requirement is that the server must install bzero agent and register itself with BastionZero on each spawned target. The server should also assign a UUID to the spawned target so that it can be torn down when it is no longer needed. When BastionZero calls out to the provisioning server, the required parameters needed to execute bzero -registrationKey on the spawned target will be provided.
  2. 2.
    Tear down a target. The provisioning server must have the ability to stop and spin down the spawned targets. BastionZero will remember the UUID the server assigned in step (1) and provide the same identifier when asking the server to stop a specific target.
Both of these functionalities should be abstracted behind two distinct HTTP POST endpoints, which the provisioning server must implement. Details on the full API specification, including a Python Flask reference implementation, is available here.
The provisioning server's architecture, due to being designed as POST webhooks, allows for dynamic targets without requiring BastionZero to have privileged access or special roles in an organization's cloud/network.

Why Use DATs

DATs encourage users to use ephemeral targets to access certain resources in an organization's network. Once the resources have been polluted by a user's access, the target may be torn down. For instance, one may require that any hands-on-keyboard database migration be performed from a fresh target container that is killed once the migration is complete.

Configuring DAT

Because DATs are dynamically created by querying a provisioning server, an organization administrator must first add a Dynamic Access configuration before other users in the organization can ask to connect to a DAT. Every DAT has a backing Dynamic Access configuration which determines how the target is spun up (provisioned) and torn down (destroyed).
An organization administrator has the ability to add a Dynamic Access configuration in the Create dropdown menu found in the top-right corner of the BastionZero web app.
Image of a DAT configuration
Below is an explanation of each configuration option.
Argument
Description
Name
A unique name that is used to refer to this Dynamic Access configuration. This is the name that appears in the Targets screen and Connect screen on the BastionZero web app. It is also the name that is used when a user wishes to connect to a DAT via the zli.
Environment
The environment that contains all DATs registered by the backing provisioning server. The environment determines the policies to apply to the spawned targets and therefore which users can access them.
Start webhook
The URL of the provisioning server's POST start endpoint. This endpoint is queried by BastionZero when it requests the server to spin up and register a target. Example: https://dynamic-access.example.com/start.
Stop webhook
The URL of the provisioning server's POST stop endpoint. This endpoint is queried by BastionZero when it requests the server to tear down a target. Example: https://dynamic-access.example.com/stop.
Health webhook
The URL of the provisioning server's GET health endpoint. This endpoint is queried by BastionZero periodically to check that the provisioning server is still online and accessible. Example: https://dynamic-access.example.com/health.
Shared secret (base64)
A shared secret between the provisioning server and BastionZero that is used to ensure only BastionZero is authorized to query the provisioning server. See more details in the reference specification's README found here.

Connecting To A DAT

Once the Dynamic Access configuration has been added, authorized users, as defined by the organization's policies, can connect to a DAT provisioned by the server specified in the configuration.
Connecting Via the zli
To connect to a dynamic access target via the zli, a user executes a command similar to the following one:
zli connect [email protected] --dynamic
db-dat is the name of the Dynamic Access configuration, and ssm-user is a default user that exists on all DATs. The user can specify a username not equal to ssm-user as long as the specified username actually exists on the provisioned machine, and there exists a policy that allows access to such Target User.

DATs Vs. Targets

Once a DAT is fully provisioned and registered, a DAT does not appear differently from the user's perspective. It is listed as an SSH target in the list of the organization's targets (Targets screen), and the user connects to it through the same flow as described above. In fact, the provisioned target is running the same bzero agent that is installed when registering a target via any autodiscovery method.
DATs differ from standard SSH targets in three ways:
  1. 1.
    How they are discovered and initially connected to by BastionZero.
  2. 2.
    The lifetime of DATs.
  3. 3.
    The policies involving DATs.

Discovery and Initial Connection

Unlike SSH targets, which are discovered by BastionZero once an administrator installs the bzero agent, DATs are discovered on a per-user basis when the user asks to connect to a DAT. A single user cannot have more than one DAT target created by the same Dynamic Access configuration. The name of discovered DATs hint at this exact property: DAT-<name-of-dynamic-access-config>-<User's full name>.
When processing the connect request, BastionZero sends a POST request to the start webhook as defined in the Dynamic Access configuration. This request notifies the provisioning server that a fresh target should be created.
Because it can take the provisioning server some time to spin up a target, the terminal shell that appears after making the initial connection will be in the loading state. The shell cannot receive any input until the target is fully provisioned - that is until the target is fully registered, online, and reachable by BastionZero.
This initial connection experience is different than when connecting to an SSH target because of the nature of a DAT. A DAT's existence is known at the time of an initial, user-initiated connection. An SSH target, on the other hand, is known at the time of registration, which happens during the autodiscovery process. Due to this difference, an initial connection to a DAT will often take longer than when connecting to an SSH target whose existence is already known ahead of time.
Notice, however, that once the initial connection is made and not closed, future DAT connections made by the same user who initially connected, will finish connecting much faster than before. This is because all future connections to the same Dynamic Access configuration will connect to the already provisioned and running DAT created for the specific user.

Lifetime of DATs

DATs are meant to be used as ephemeral targets; therefore, the lifetime of a DAT is fairly short compared to an SSH target. A DAT target is automatically deleted once there are no more connections to it. When the last connection is closed, BastionZero sends a POST request to the stop webhook as defined in the Dynamic Access configuration. This request notifies the provisioning server that the backing machine should be destroyed and is no longer needed.
An SSH target, on the other hand, will not be deleted unless the user explicitly deletes it from the Targets screen or if the environment's offline target removal policy timeout is reached.

Policies of DATs

Similar to other kinds of targets, DATs are protected by the organization's policies. The two types of Target Access policies, environment-specific and target-specific, are applicable to DATs. However, there is a notable difference in a target-specific policy compared to SSH targets. A target-specific policy cannot refer to one of the spawned DATs; it can only refer to a specific Dynamic Access configuration.
The effect of this difference is as follows:
  • If the organization only has a target-specific policy for some Dynamic Access configuration, authorized users can only access the DATs created for them (i.e., the ones with the name DAT-<name-of-dynamic-access-config>-<User's full name>).
  • If an administrator wants to allow users to access DATs that were not created for them, then an environment-specific policy that refers to the Dynamic Access configuration's environment must be used.

SSH Tunnels & Secure File Copy

To configure your server target to utilize tunnels or file copy, ensure the BastionZero agent is already installed, registered, and online.
With BastionZero SSH tunneling, there is no need to utilize SSH keys; instead, BastionZero automatically sets up a one-time-use SSH key for each tunnel. You can then use your native SSH clients and scripts to connect to targets that are autodiscovered to BastionZero.
Diagram of ssh tunneling in BastionZero
The figure shows the architecture for the SSH tunnel. The connection from your SSH client is routed through BastionZero's zli. The zli then creates an SSH tunnel directly to the target. The SSH tunnel is passed over a web socket from the zli to BastionZero. From there, it is passed over a different web socket from BastionZero to the target.
If a user wants to access a target via an SSH tunnel, there must a policy in BastionZero that allows that user to do so.
At this time, BastionZero does not have the ability to read the contents of the SSH tunnel so command logging is not possible with SSH tunneling. However, BastionZero logs do capture the establishment of the SSH tunnel and its duration.

Setting It Up

Run zli generate ssh-proxy and configure your .ssh/config file with two lines:
host bzero-\*
IdentityFile /home/user/.config/bastionzero-zli-nodejs/bzero-temp-key
ProxyCommand /home/user/zli ssh-proxy -s %h %r %p /home/user/.config/bastionzero-zli-nodejs/bzero-temp-key
For simple access, just prefix the host with bzero:
You can tunnel to a remote server application using the below.
$ ssh -L 6100:127.0.0.1:5432 [email protected]
You can also tunnel using a client browser to reach an HTTP application on your local network.
$ ssh -L 8080:10.0.0.1:80 [email protected]
For more information on SSH tunnels, check out the SSH tunneling man page.
Copyright © 2023