Search…
zli Reference Manual

Overview

The BastionZero zli is an exec level command line interface client that provides users the ability to connect, tunnel, and manage their targets' policies.

Open Source & Distribution

The zli is an open-source project licensed under the Apache License, version 2.0. The project is available for download through a variety of Linux package managers (i.e., apt, brew, yum). See more details here.
The project is also available from the BastionZero GitHub repositories and can be found here: BastionZero zli.
Installation information is found in the open-source documentation.
We highly recommend installing from the package manager of your choice for simplicity.
Pro tip: For convenience, move your download of the zli into your bin $PATH. (Read more about $PATH)

Command Summary

The following tables list all the zli commands and their functions.
You can run zli help at any time to list all the available commands in the CLI.
Command
Description
login
Authenticates a user to the service using an identity provider (IdP)
connect
Connect to an SSM or dynamic access target (DAT)
tunnel
Tunnel to a Kubernetes cluster
Update the default target group used when tunneling to a Kubernetes cluster
policy
List the organization's policies
Get detailed information about what policies apply to a certain cluster
Disconnect the bctl daemon
attach
Attach to an open zli connection
close
Close an open zli connection
List all targets
List all open zli connections
user
List all of the organization's IdP users. Add or remove a policy's IdP users
group
List all of the organization's IdP groups. Add or remove a policy's IdP groups
List, add, or remove a policy's target users
List, add, or remove a policy's target groups
Generate ssh configuration to be used with the ssh-proxy command
ssh-proxy
Tunnel an SSH connection to an SSM target
configure
Returns the configuration path for the zli client
Generate a bash script to autodiscover an SSM target
Start an interactive onboarding session to add your SSH hosts to BastionZero
generate
Generate different types of configuration files for use with Kubernetes targets
logout
Deauthenticate the client
kube
kubectl wrapper

Global Flag Options

The zli includes a few global options that can be used with any command.
Flag Option
Description
--version
Show zli version number
--debug
Show debug events
-s, --silent
Silence all zli output messages
--help
Show command help

Command Manual

The following section documents each zli command operation listed in the overview above.

login

Synopsis

1
zli login [--mfa <code>]
Copied!

Description

The login command authenticates a user to the BastionZero service. When executed, a new window is opened in the user's default browser. The user may then select their IdP and authenticate by supplying their username and password. This is accomplished using the Open ID Connect (OIDC) specification.

Options

  • -m, --mfa: MFA code to pass to BastionZero if the organization has required MFA.

connect

Synopsis

1
zli connect <targetString> [--targetType dynamic]
Copied!

Description

The connect command spawns an interactive shell to a SSM target or dynamic access target (DAT) as indicated by the <targetString>.
The <targetString> is required and must be in the format [email protected]:
  • targetUser: The UNIX username to login as.
  • targetName: The name or UUID of an SSM target or DAT configuration. In cases where there is a name conflict, i.e., two or more targets with the same name, then the UUID must be supplied.
The logged-in zli user must have a Target Connect policy that covers this targetUser and target combination.

Options

  • --targetType dynamic: Specifies that this connection is to a DAT.

Examples

tunnel

Synopsis

1
zli tunnel [<tunnelString>] [--customPort <portNumber>] [--targetGroup <groupName>[,...]]
Copied!

Description

The tunnel command is used to connect to a Kubernetes cluster.
If <tunnelString> is provided:
The tunnel command spawns the bctl daemon on an available port of the user's machine. The daemon interacts with the Kubernetes cluster specified by the <tunnelString>. Once executed, users can interact with their registered cluster using various Kubernetes tools (e.g. kubectl or Lens) by pointing their kubeconfig file to the daemon's localhost HTTP server. You can learn more about using third party tools with BastionZero and Kubernetes here.
The <tunnelString> must be in the format [email protected]:
  • targetUser: The Kubernetes RBAC user to impersonate as. All Kubernetes API calls forwarded by the bctl daemon will authenticate as this user and assume that user's role and cluster bindings.
  • targetName: The name of the Kubernetes cluster.
The logged-in zli user must have a Kubernetes Access policy that covers this targetUser and cluster target combination.
If <tunnelString> is not provided:
The tunnel command will output information about the tunnel connection if there is one currently running.

Options

  • --customPort: Forces the bctl daemon to run on a specific port.
  • --targetGroup: Comma separated list of Kubernetes RBAC groups to impersonate as. In addition to authenticating as the specified targetUser, the bctl daemon will authenticate as these groups and assume their role and cluster bindings. The logged-in zli user must have a Kubernetes Access policy that covers this list of groups and cluster target.

Examples

  • zli tunnel [email protected] - Start the bctl daemon and connect it to my-cluster as Kubernetes RBAC user admin.
  • zli tunnel [email protected] --targetGroup system:masters - Start the bctl daemon and connect it to my-cluster as Kubernetes RBAC user alice and RBAC group system:masters.

default-targetGroup

Synopsis

1
zli default-targetGroup [--groups <groupName>[,...]] [--view]
Copied!

Description

The default-targetGroup command updates a local configuration value that specifies the default target groups to use when executing zli tunnel.

Options

  • -g, --groups: Comma separated list of Kubernetes RBAC groups. If this flag is not provided, then the default target group is set back to nothing.
  • -v, --view: View the local configuration's current default group.

policy

Synopsis

1
zli policy [--type (targetconnect|organizationcontrols|sessionrecording|kubernetestunnel)] [--json]
Copied!

Description

The policy command lists the organization's policies.

Options

  • -t, --type: Policy type filter. If this flag is not provided, then all types of policies will be returned.
  • -j, --json: Output the list of policies in JSON format.

Examples

  • zli policy --json --silent | jq - List all policies. Output as JSON.
Pro tip: Pipe into jq for pretty formatting.

describe-cluster-policy

Synopsis

1
zli describe-cluster-policy <clusterName>
Copied!

Description

The describe-cluster-policy command returns detailed information about what policies apply to the <clusterName> cluster.

Options

There are no options for this command besides the global ones.

disconnect

Synopsis

1
zli disconnect
Copied!

Description

The disconnect command stops the tunnel connection to a Kubernetes cluster if there is one currently running. The bctl daemon process is killed.

Options

There are no options for this command besides the global ones.

attach

Synopsis

1
zli attach <connectionId>
Copied!

Description

The attach command attaches to an open zli connection. A zli connection is defined as one that exists in the cli-space; all connections created with the connect command exist in this space.

Options

There are no options for this command besides the global ones.

close

Synopsis

1
zli close (<connectionId>|--all)
Copied!

Description

The close command closes an open zli connection. A connection that has been closed can no longer be attached to. A zli connection is defined as one that exists in the cli-space; all connections created with the connect command exist in this space.

Options

  • -a, --all: Closes all connections in the cli-space.

list-targets

Synopsis

1
zli list-targets [--targetType (ssm|dynamic|cluster)] [--env <environmentName>] [--name <targetName>]
2
[--status (notactivated|offline|online|terminated|error)] [--detail] [--showId] [--json]
Copied!

Description

The list-targets command lists all the organization's targets. Optional result filters can be applied by passing in flags as described below. The returned table of targets includes the type, name, and environment of all targets.
Alias: lt

Options

  • -a, --all: Closes all connections in the cli-space.
  • -t, --targetType: Target type filter.
  • -e, --env: Environment name filter.
  • -n, --name: Target name filter.
  • -u, --status: Target status filter.
  • -d, --detail: Returns extra detail in the output. The additional information includes the target's agent version, status, and suitable target users to use in the user portion of the <targetString> and <tunnelString> syntax.
  • -i, --showId: Display the target's UUID in the output.
  • -j, --json: Output the list of targets in JSON format.

Examples

  • zli lt -i -t cluster - List all Kubernetes cluster targets. Display the target's UUID.
  • zli lt --json --silent | jq - List all targets. Output as JSON. Pipe into jq for pretty formatting.

list-connections

Synopsis

1
zli list-connections [--json]
Copied!

Description

The list-connections command lists all open zli connections. A zli connection is defined as one that exists in the cli-space; all connections created with the connect command exist in this space.
Alias: lc

Options

  • -j, --json: Output the list of connections in JSON format.

user

Synopsis

1
zli user [<policyName> <idpUserEmail> (--add|--delete)]|[--json]
Copied!

Description

The user command lists all the organization's IdP users or adds/removes a user to/from a specific policy.
If no positional arguments are provided (i.e., zli user is executed by itself), then a list of all the organization's users is returned. The returned table includes the user's name, <idpUserEmail>, role (admin or user), and time of last login.
When adding/removing a user (specified by --add or --delete), both <policyName> and <idpUserEmail> must be provided. <policyName> should refer to a policy that exists in the list of the organization's policies (see the policy command). <idpUserEmail> should refer to the email of one of the organization's users.

Options

  • -a, --add: Specifies that the provided user should be added to the policy.
  • -d, --delete: Specifies that the provided user should be removed from the policy.
  • -j, --json: Output the list of users in JSON format.

Examples

group

Synopsis

1
zli group [<policyName> <idpGroupName> (--add|--delete)]|[--json]
Copied!

Description

The group command lists all the organization's IdP groups or adds/removes a group to/from a specific policy.
If no positional arguments are provided (i.e., zli group is executed by itself), then a list of all the organization's groups is returned.
When adding/removing a group (specified by --add or --delete), both <policyName> and <idpGroupName> must be provided. <policyName> should refer to a policy that exists in the list of the organization's policies (see the policy command). <idpGroupName> should refer to the name of one of the organization's groups.

Options

  • -a, --add: Specifies that the provided group should be added to the policy.
  • -d, --delete: Specifies that the provided group should be removed from the policy.
  • -j, --json: Output the list of groups in JSON format.

targetUser

Synopsis

1
zli targetUser <policyName> [<targetUser> (--add|--delete)]|[--json]
Copied!

Description

The targetUser command lists, adds, or removes a specific policy's target users. Target users determine what UNIX users or Kubernetes RBAC users are permissible to use in the connect and tunnel commands respectively.
If only the <policyName> positional argument is provided, then a list of that policy's target users is returned.
When adding/removing a target user (specified by --add or --delete), <targetUser> must be provided. <targetUser> refers to a UNIX username when editing a Target Connect policy. <targetUser> refers to a Kubernetes RBAC user when editing a Kubernetes Access policy.

Options

  • -a, --add: Specifies that the provided target user should be added to the policy.
  • -d, --delete: Specifies that the provided target user should be removed from the policy.
  • -j, --json: Output the list of target users in JSON format.

targetGroup

Synopsis

1
zli targetGroup <policyName> [<targetGroup> (--add|--delete)]|[--json]
Copied!

Description

The targetGroup command lists, adds, or removes a specific policy's target groups. Target groups determine which Kubernetes RBAC groups are permissible to use in the tunnel command. This command only applies to Kubernetes Access policies.
If only the <policyName> positional argument is provided, then a list of that policy's target groups is returned.
When adding/removing a target user (specified by --add or --delete),<targetGroup> must be provided. <targetGroup> refers to a Kubernetes RBAC group.

Options

  • -a, --add: Specifies that the provided target group should be added to the policy.
  • -d, --delete: Specifies that the provided target group should be removed from the policy.
  • -j, --json: Output the list of target groups in JSON format.

ssh-proxy-config

Synopsis

1
zli ssh-proxy-config
Copied!

Description

The ssh-proxy-config command generates an ssh configuration block to be added to the user's ssh_config file. The generated configuration block allows the ssh command to tunnel SSH connections to SSM targets by calling the zli's ssh-proxy command behind the scenes.
This command only needs to be executed once, with the user taking the actions as specified in the output of the command to modify their ssh_config ($HOME/.ssh/config) file. After doing so, the user may utilize SSH tunneling by using ssh and specifying the correct hostname prefix (i.e., bzero-*).
See the following article for more information.

Options

There are no options for this command besides the global ones.

ssh-proxy

Synopsis

1
zli ssh-proxy <hostString> <userName> <portNumber> <identityFile>
Copied!

Description

The ssh-proxy command allows for proxying an SSH connection to an SSM target. The captured SSH connection can be an interactive shell or a port forwarding tunnel.
Users should typically not use this command directly. Instead, they should let ssh call it via the ProxyCommand directive.
<hostString> includes the SSM target's name or UUID in the case there are two or more targets with the same name. <userName> is the UNIX username to login as. <portNumber> refers to the port number on the SSM target running the sshd daemon. <identityFile> refers to the private SSH key generated by the zli.
The logged-in zli user must have a Target Connect policy that covers this userName and target combination. The Tunnel action must be enabled in the policy.
See the following article for more information.

Options

There are no options for this command besides the global ones.

configure

Synopsis

1
zli configure
Copied!

Description

The configure command returns the file path of both the zli's configuration and the logs kept as part of normal client operation. These files typically do not need to be configured or modified by a user.

Options

There are no options for this command besides the global ones.

generate-bash

Synopsis

1
zli generate-bash [--environment <environmentName>] [--agentVersion <version>] [--os (centos|ubuntu|universal)]
2
[--outputFile <filePath>] [(--targetName <name>|--targetNameScheme (do|aws|time|hostname))]
Copied!

Description

The generate-bash command generates a bash script that is used to autodiscover an SSM target. The script should be executed on the target machine to connect with BastionZero.

Options

  • -e, --environment: Specifies the environment the target will belong to once registered. Defaults to the Default environment if this flag is not provided.
  • --agentVersion: Use a specific version of the agent when installing the agent on the target. Defaults to the latest version if this flag is not provided.
  • --os: Force the script to assume the target is running a specific operating system. If this flag is not provided, the script will automatically infer the target machine's OS.
  • -o, --outputFile: Writes the bash script to a file on the user's machine.
  • -n, --targetName: Sets the target name explicitly.
  • --targetNameScheme: Configures the target name from a specific source. Defaults to the hostname source if this flag is not provided.
    • do: If the target machine is a DigitalOcean droplet, the target name will be set to the droplet's name.
    • aws: If the target machine is an AWS EC2 machine, the target name will be set to the instance's ID.
    • time: The target name will be set to target-%m%d-%H%M%S, where the variables are date formats. The formatted timestamp is the time the script is executed on the target machine.
    • hostname: The target name will be set to the machine's hostname.

quickstart

Synopsis

1
zli quickstart [--sshConfigFile <filePath>]
Copied!

Description

The quickstart command starts an interactive onboarding session that adds the user's SSH hosts, as specified by the the ssh_config file, to BastionZero.
See the following article for more information.

Options

  • -c, --sshConfigFile: Path to ssh_config file. Defaults to $HOME/.ssh/config if this flag is not provided.

generate

Synopsis

1
zli generate (kubeConfig [--customPort <portNumber>] [--outputFile <filePath>] [--update])
2
| (kubeYaml <clusterName> [--labels <labelName>[,...]] [--environmentName <environmentName>] [--namespace <namespaceName>] [--outputFile <filePath>])
Copied!

Description

The generate command generates different types of configuration files required for registering and accessing a Kubernetes cluster with BastionZero.
zli generate kubeConfig (Access):
zli generate kubeConfig creates the kubeconfig file that sets up the user's local Kubernetes tools (e.g. kubectl, Lens) to communicate with a registered Kubernetes cluster. The generated kubeconfig configures a new context, bctl-agent-context, which when set as the current-context, allows for local Kubernetes tools to talk with the bctl daemon. The bctl daemon forwards all Kubernetes API calls to the currently connected Kubernetes cluster (see tunnel command).
zli generate kubeYaml <clusterName> (Registration):
zli generate kubeYaml <clusterName> creates a Kubernetes .yaml file that can be applied via kubectl apply to a cluster the user wishes to register with BastionZero.
See the following article for more information.

Options

  • --customPort: Configures the bctl-agent-context to connect to the bctl daemon server on a different port than the one currently listed in the user's local configuration.
  • -o, --outputFile: Writes the generated configuration to a file on the user's machine.
  • --update: Updates the user's existing kubeconfig file (defaults to $HOME/.kube/config unless KUBECONFIG is set). Requires kubectl to be installed on the user's machine and exist in their $PATH.
  • --labels: Comma separated list of Kubernetes labels to add to the bctl-agent deployment that is installed when registering a cluster with BastionZero.
  • --environmentName: Sets the BastionZero environment this cluster should be added to once registered.
  • --namespace: Sets the namespace for all bctl-agent-related Kubernetes objects that are created during registration and used during the lifetime of the agent.

logout

Synopsis

1
zli logout
Copied!

Description

The logout command de-authenticates the client. The user must run login again to be able to run other zli commands.

Options

There are no options for this command besides the global ones.

kube

Synopsis

1
zli kube -- <kubeCtlArg> ...
Copied!

Description

The kube command passes all the supplied <kubeCtlArg> arguments to the kubectl CLI tool.
The user should not run this command unless the following requirements have been met:
  • The bctl daemon must be running and connected to a Kubernetes cluster (see tunnel command).
  • kubectl must be installed on the user's machine and exist in their $PATH.
  • The user's current-context configured in their kubeconfig file should be set to the bctl context (see zli generate kubeConfig).

Options

There are no options for this command besides the global ones.
Last modified 9d ago