bt CLI guide
Overview
The bt command-line interface (CLI) lets you use BeyondTrust Privileged Remote Access (PRA) features from a terminal. You type short commands instead of clicking through the Access console. With bt, you can do the following:
- Start Jump sessions. Open SSH, RDP, database, Kubernetes, and port tunnel sessions to Jump Items.
- Manage active sessions. List, inspect, and close the sessions you have open.
- Find Jump Items. See which Jump Items you can reach and which ones are online.
- Work with vault credentials. Get, check out, and check in credentials. You can also run a command with credentials added to its environment, so you never type or paste a password.
- Use your own SSH tools. Generate SSH config entries so that standard
ssh,scp, andrsynccommands create BeyondTrust sessions in the background.
The CLI works with the Access console. It does not replace it. When you run a bt command, the CLI sends the request to the console running on your computer, and the console does the work.
Why it matters
Many administrators and engineers spend most of their day in a terminal. Switching to a console to start a session or look up a password slows them down. The bt CLI keeps that work in one place.
The CLI also makes automation safer and easier:
- Scripts behave predictably. The CLI returns standard exit codes and passes along exit codes from tools like
sshandpsql. Scripts that useset -eor&&work as expected. - Credentials stay protected.
bt vault runadds credentials to a command's environment and checks them back in when the command finishes. Secrets do not appear in your shell history or scripts. - The CLI blocks risky mistakes. It refuses to print a private key unless you ask for it by name. It also rejects requests that do not match the account type, such as asking for a password on an SSH key account.
- Every session goes through BeyondTrust. Even when you use plain
ssh, the connection runs as a BeyondTrust session. Your organization keeps the same access controls and session records.
Prerequisites
Before you use the bt CLI, make sure you meet these requirements:
- The Access console is running and you are signed in. The CLI talks to the console on your computer. If the console is not running,
btcommands do not work. - Your account has CLI access. An administrator must turn on the allow_rep_cli permission for your account.
- The bt shim is installed. In the Access console, go to Settings > Global Settings > CLI, and then click Install. The console installs
btto the following locations:- macOS and Linux:
~/.sra-con/CLI/bt - Windows:
%LocalAppData%\BeyondTrust\sra-con\CLI\bt.exe
- macOS and Linux:
- Optional: Static port permission for SSH config. To use
bt ssh-configorbt ssh --proxy, your account also needs the Static port and username for external tool sessions permission (perm_sd_static_port_for_external_tools). These two commands do not work on Windows. On Windows, usebt ssh <item>instead. - Optional: jq for shell completion. Bash and zsh completion scripts install with the shim. To complete active session numbers, you also need
jq.
Quick start
These commands cover the most common tasks:
# Check your connection
bt status
# List the Jump Items you can access
bt items
# Start an SSH session
bt ssh my-prod-server
# Get a password from the vault
bt vault get prod-admin
# Generate SSH config entries, and then connect with plain ssh
bt ssh-config > ~/.ssh/config.d/bt
ssh my-server.btCommands
Jump sessions
Jump session commands match your query against a Jump Item's hostname, computer name, or display name. You can use these formats:
| Format | How it matches |
|---|---|
user@host | Matches by username and hostname. This is the most specific option. |
host | Matches by hostname or name only. The username comes from the Jump Item settings. |
name | Matches by the Jump Item display name. |
If more than one Jump Item matches, the CLI shows a list so you can pick the right one.
bt ssh
bt ssh [user@]<host|name> [--account <account>] [--proxy]Starts an SSH or Shell Jump session.
| Option | Description |
|---|---|
--account, -a | Uses a vault account to supply credentials. |
--proxy | Runs in stdio proxy mode for use as an SSH ProxyCommand. Requires the static port permission. Not available on Windows. For details, see SSH config integration. |
The CLI never matches Telnet Shell Jump Items, because they cannot complete an SSH handshake.
bt ssh [email protected]
bt ssh my-prod-server
bt ssh my-prod-server --account prod-admin
bt ssh my-prod-server --proxybt rdp
bt rdp [user@]<host|name> [--account <account>]Starts an RDP Jump session. It uses the same matching rules as bt ssh.
bt rdp admin@win-server-01
bt rdp my-windows-boxbt db
bt db [user@]<host|name> [--account <account>]Starts a database Jump session. Supported databases include MSSQL, PostgreSQL, MySQL, MongoDB, and Oracle. The username is optional, because the CLI matches database items by hostname or name.
bt db prod-mysql-01
bt db prod-db --account db-adminbt k8s
bt k8s [user@]<host|name> [--account <account>]Starts a Kubernetes Jump session.
bt k8s my-clusterbt pt
bt pt <host|name>Starts a port tunnel (TCP) session.
bt pt 10.0.0.5Session management
bt list
bt list [--json]Lists all active sessions with their session numbers, names, and connection details.
bt list
bt list --json | jq '.[].name'bt info
bt info <session number> [--json]Shows details for one session, including tunnel endpoints, listen addresses, and ports.
bt info 1
bt info 1 --json | jq '.tunnels'bt close
bt close <session number>Closes an active session. The CLI does not close a session that has an active file transfer.
bt close 1Discovery
bt items
bt items [ssh|rdp|db|pt|k8s] [--json] [--available]Lists the Jump Items you can access through the CLI. You can filter the list by type.
By default, the list includes both online and offline items. Add --available to show only items whose Jumpoint is online right now. The list never includes Telnet Shell Jump Items.
bt items # All CLI-accessible items
bt items ssh # SSH items only
bt items --available # Only items that are online right now
bt items --json # Machine-readable output
bt items ssh --json | jq '.[].name'bt status
bt status [--json]Shows your connection status: the site hostname, the logged-in user, and the number of active sessions. If the Access console is not running, the command stops working with an error.
bt status
bt status --jsonVault
bt vault list
bt vault list [--json]Lists all vault accounts you can access, with each account's name, username, type, and group.
bt vault list
bt vault list --json | jq '.[] | select(.type == "ssh")'bt vault get
bt vault get <account-query>[/<attribute>]Gets one attribute from a vault account.
You can request these attributes: password, username, name, description, id, type, private_key, public_certificate, and secret.
Secret attributes (password, private_key, public_certificate, and secret) trigger a checkout and check in.
If you do not name an attribute, the CLI picks one based on the account type:
| Account type | What happens |
|---|---|
| Password-style (local, domain, and similar) | Returns password. |
| Opaque token | Returns secret. |
| Key-based (SSH, SSH CA, x509 CSR) | Refuses the request. SSH: name private_key or public_certificate, or use bt vault checkout. SSH CA and x509 CSR: use bt vault checkout |
SSH CA and x509 CSR accounts refuse every secret attribute, not only the bare form. Each checkout issues a new key and certificate, so separate get calls would return halves of two different pairs. Use bt vault checkout, which writes a matching pair. Non-secret attributes such as username still work.
The CLI refuses key-based requests on purpose. A plain bt vault get <ssh-account> looks like a harmless lookup, but it would print a private key to your screen.
The CLI also checks each attribute against the account type. For example, if you ask for password on an SSH account, the CLI returns an error instead of quietly showing the private key.
bt vault get prod-admin # Gets the password (default)
bt vault get prod-admin/username # Gets the username
bt vault get shared/prod-group/db-admin # Gets a shared account in a group
bt vault get personal/my-key/private_key # Gets a personal SSH key (attribute required)bt vault checkout
bt vault checkout <account-query> [directory]For SSH, SSH CA and x509 accounts, the CLI writes key files to the folder you name. The folder is required and must already exist.
On macOS and Linux, the CLI sets owner-only permissions on each key file before it writes any key data. On Windows, file permissions are inherited from the target folder.
Key files are named id_
Characters that are not valid in a file name on every platform (/ \ : * ? " < > | and control characters) become _, so username CORP\svc on account 42 is written as id_CORP_svc_42.
bt vault checkout my-ssh-key ~/.ssh/bt vault checkin
bt vault checkin <account-query>Checks in credentials you checked out earlier. You cannot check in personal accounts.
bt vault checkin my-ssh-keybt vault run
bt vault run [-a <account>] [-e VAR=attr]... [env-file] -- <command> [args...]Runs a command with vault credentials added to its environment.
Put all options before a single --. Everything after -- is the command and its arguments. The CLI passes them exactly as typed and starts the command without a shell, so it does not reprocess quotes, wildcards, or $VAR values.
Account injection (-a)
-a)The -a option adds the account's credentials as BT_* environment variables:
| Variable | Value |
|---|---|
BT_USERNAME | Account username |
BT_PASSWORD | Account password (password-style accounts) |
BT_TOKEN | Secret (opaque token accounts) |
BT_PRIVATE_KEY | Private key (key-based accounts) |
BT_ACCOUNT_NAME | Account display name |
BT_ACCOUNT_TYPE | Account type (local, domain, ssh, and so on) |
BT_ACCOUNT_ID | Account numeric ID |
The CLI puts each secret in the variable that matches what it is. For example, it never puts a private key in BT_PASSWORD.
Custom mapping (-e)
-e)The -e option maps an account attribute to an environment variable name you choose. You can repeat it, and it requires -a. Every mapping must succeed. The CLI stops with an error if a mapping uses an attribute that does not fit the account type (such as -e X=password on an SSH account), an unknown attribute, an empty value, or a duplicate variable name.
# Add credentials as BT_* variables
bt vault run -a prod-admin -- psql -h mydb
# Map attributes to custom variable names
bt vault run -a prod-admin -e PGPASSWORD=password -e PGUSER=username -- psql -h mydb
# Use an env file with bt-vault:// URIs
echo 'DB_PASS=bt-vault://shared/prod/dbadmin/password' > .env
bt vault run .env -- psql -h mydb
# Resolve bt-vault:// URIs already exported in your shell
export DB_PASS=bt-vault://shared/prod/dbadmin/password
bt vault run -- mycommand
# Combine account injection with an env file
bt vault run -a prod-admin .env -- mycommandThe CLI always scans your environment for bt-vault:// values, so the second-to-last example doesn't need -a. The CLI checks out each referenced account once, and then checks it back in once after it resolves every variable that uses that account.
Account query syntax
Vault commands accept these account query formats:
| Format | Example | Description |
|---|---|---|
<name> | prod-admin | Matches by account name or username. |
<id> | 42 | Matches by account numeric ID. |
personal/<name> | personal/mykey | Matches a personal account. |
shared/<name> | shared/db-admin | Matches a shared account in any group. |
shared/<group>/<name> | shared/prod-group/db-admin | Matches a shared account in a specific group. |
SSH config integration
Requirements: SSH config integration needs the Static port and username for external tool sessions permission (perm_sd_static_port_for_external_tools). It does not work on Windows.
ImportantWithout this permission, BeyondTrust issues a unique tunnel key for each session, and the SSH client must send that key as its username. The CLI writes the config file before any session exists, and OpenSSH locks in the
Uservalue when it reads the file. A pre-generated entry cannot supply a key that does not exist yet, so every connection would fail. To prevent this,bt ssh-configandbt ssh --proxystop right away and show a message that names the missing permission.
bt ssh-config
bt ssh-config [--filter <text>] [--group <name>]Generates SSH config Host entries for the SSH Jump Items you can access. The CLI prints the output to your screen, so you can send it to an SSH config file.
Each entry uses ProxyCommand bt ssh --proxy ..., so running ssh <alias> creates a BeyondTrust session in the background.
| Option | Description |
|---|---|
--filter | Includes only items whose name or computer name contains the text. Not case-sensitive. |
--group | Includes only items in the named Jump Group. Not case-sensitive. |
# Preview the output
bt ssh-config
# Write to a separate config file (recommended)
bt ssh-config > ~/.ssh/config.d/bt
# Then add this line to ~/.ssh/config: Include config.d/*
# Narrow the output
bt ssh-config --filter prod --group "My Group"
# Or add the entries directly to your main config
bt ssh-config >> ~/.ssh/configGenerated format
# Generated by bt ssh-config
# Re-run 'bt ssh-config' to regenerate after jump item changes.
# Jump item: My Production Server
Host my-production-server.bt
ProxyCommand bt ssh --proxy admin@my-production-server
StrictHostKeyChecking askThe CLI still includes offline items and marks them with a # (currently offline) comment. You keep the config file for a long time, and the item's Jumpoint might be online when you use it.
StrictHostKeyChecking ask prompts you the first time you connect, instead of quietly trusting a new host key. Because each entry has no HostName, the known_hosts file stores keys under the stable alias for each Jump Item, not under a temporary local port.
Alias names
The CLI builds each alias from the Jump Item name. It changes the name to lowercase, adds .bt to the end, and replaces any character that is unsafe for the shell or meaningful to ssh_config with a dash. For example, "My Prod Server" becomes my-prod-server.bt.
Replacing these characters prevents real problems:
ssh_configreadsHostlines as patterns and uses the first match.- A
*or?in an alias could match and take over other aliases. - A
,splits oneHostline into several patterns. - A
#starts a comment, and=acts as a separator.
The CLI targets items by Jump Item name. If two items share a name, the CLI adds the username to the alias, such as admin-my-prod-server.bt. If it still can't tell items apart, or if an item contains characters that would break the config format, the CLI skips the item and lists it in a comment at the end of the output.
After you generate the config, you can use standard SSH tools:
ssh my-prod-server.bt # Creates a session in the background
scp file.txt my-prod-server.bt: # Works with scp
rsync -avz ./dir my-prod-server.bt:/path/ # Works with rsyncThe CLI creates the session when the SSH connection starts and closes it when the connection ends.
bt ssh --proxy
The --proxy option puts bt ssh into stdio proxy mode. Instead of opening an SSH client, it connects your standard input and output to the SSH tunnel. SSH uses this mode as a ProxyCommand. You do not run it directly.
The session lasts only while the proxy process runs. When SSH disconnects, the proxy exits and the session closes. If you press Ctrl+C, the CLI restores your terminal and closes the session, even if the session is still waiting for approval.
Help
bt --help
bt --help
bt -hShows a summary of all commands.
bt <command> --help
Shows help for a specific command. This works for every command.
bt ssh --help
bt vault --help # Shows subcommands and account query examples
bt items --helpOutput formats
Most commands support --json, which returns output that scripts can read:
bt items --json | jq '.[] | select(.type == "ssh") | .name'
bt list --json | jq '.[].number'
bt status --json | jq '.activeSessions'
bt vault list --json | jq '.[] | select(.personal == true)'
bt info 1 --json | jq '.tunnels[0].listenPort'By default, the CLI shows human-readable output. JSON output is always a valid JSON array or object.
Shell completion
When you install the CLI from the console, it also installs bash and zsh completion scripts in the same folder as bt. You do not need to copy them. You only need to point your shell to them.
Bash
source ~/.sra-con/CLI/bt.bash
# Or copy the file to /etc/bash_completion.d/btZsh
# The script installs as _bt, not bt.zsh. Zsh loads a #compdef
# script by file name, so any other name does nothing.
fpath=(~/.sra-con/CLI $fpath) # Add to .zshrc, before compinit
autoload -Uz compinit && compinitTo regenerate the scripts or install them somewhere else, print them from the CLI. This works even when the console is not running:
bt --completions bash > /etc/bash_completion.d/bt
bt --completions zsh > ~/.zsh/completions/_btCompletion covers subcommands, type filters, options, and active session numbers for close and info. Session number completion uses bt list --json | jq. If jq isn't installed, completion covers options only.
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error, such as permission denied, item not found, invalid arguments, or timeout |
| Other | Passed through from a child process, such as an SSH exit code |
The CLI passes along exit codes from child processes like ssh and psql. This keeps set -e scripts and && chains working correctly.
Troubleshooting
| Message | Cause and resolution |
|---|---|
| There are active transfers for this session | The bt close command was run with an active file transfer.Wait for the file transfer to finish or cancel it from the user interface. |
| bt ssh --proxy requires permission to use a static port and username for external tool sessions. Without it this session is issued a tunnel key that must be sent as the SSH username, which an ssh_config alias cannot do. | The bt ssh --proxy command does not have the proper permissions.Ask your administrator to enable perm_sd_static_port_for_external_tools. |
| Unable to connect to console for <host> | The Access console is not running, you aren't logged in, or your account does not have CLI permission. Start the console, log in, and ask your administrator to confirm the allow_rep_cli permission. If you do not have allow_rep_cli you see the message, CLI access is not permitted. |
| Timed out waiting for a response from the console. | The console is busy, or session setup took longer than two minutes. Try the command again. |
| Unable to locate a matching Jump Item that is not already in session. | No available Jump Item matches your query, or the matching item already has an active session. Check the name with bt items, or close the existing session. |
| Multiple items match. Please be more specific: | Your query matches more than one Jump Item. Use the user@host format or the exact Jump Item name. |
| You do not have permission or are not configured to open Shell Jump Items or RDP Jumps with an external tool. | The Open SSH in external tool setting is off. Turn it on in the Access console preferences. |
| bt ssh-config requires permission to use a static port and username for external tool sessions. | Your account does not have perm_sd_static_port_for_external_tools. Without it, each session gets a unique tunnel key that the SSH client must send as its username, and a pre-generated config cannot do that.Ask your administrator to turn on the permission. This also applies to bt ssh --proxy. |
| bt ssh-config is not supported on Windows because SSH proxy mode is unavailable there. | --proxy, and therefore ssh-config, works only on macOS and Linux.On Windows, use bt ssh <item>, which opens your configured external tool directly. |
| An invalid username was provided during connection. | This appears in the session chat when an SSH client connects through a tunnel without the expected tunnel key as its username. This happens with a hand-written Host entry, or with a config generated before you received the static port permission.Run bt ssh-config again to regenerate the config. |
| Canceled credential prompt | Canceling the console's Enter Credentials prompt used to exit 0 and print a space to stdout. It now exits 1. |
Updated 8 days ago