Install the SecretHub CLI

Before creating an account and writing your first secret, you need to install the SecretHub CLI, called secrethub.

The CLI is open source and available on GitHub here: https://github.com/secrethub/secrethub-cli, but we also provide some handy installation methods.

Installation Methods

Choose any of the following installation methods that best fits your environment:

Mac OSX

To install the CLI using Homebrew, run:

brew install secrethub/tools/secrethub-cli

First download the latest release.

To install, extract it to a directory of your choosing, for example:

mkdir -p /usr/local/secrethub
tar -C /usr/local/secrethub -xzf secrethub-vx.x.x-os-architecture.tar.gz

Note: depending on your OS configuration, you may need root priviliges to write to the /usr/local directory.

Ensure the binary is accessible by symlinking to it from a directory that is on your PATH environment variable, for example:

ln -s /usr/local/secrethub/bin/secrethub /usr/local/bin/secrethub

Linux

To install the CLI using Snapcraft, run:

snap install secrethub-cli

To install the CLI using [Snapcraft][snapcraft]{:target=”_blank”}, run:

snap install secrethub-cli

Sandboxing

Snapcraft sandboxes its apps, so the directory where the SecretHub credential gets stored is not the usual /$HOME/.secrethub, but $HOME/snap/secrethub-cli/<revision>/.secrethub instead. When you snap remove an app, the entire Snap home of the app gets deleted, so make sure you don’t lose your SecretHub credential.

If you want to change this behavior, set the SECRETHUB_CONFIG_DIR environment variable:

export SECRETHUB_CONFIG_DIR=$HOME/.secrethub

To install the CLI using apk, you first need to add the SecretHub public key to your /etc/apk/keys:

apk add curl
curl -fsSLo /etc/apk/keys/secrethub.rsa.pub https://alpine.secrethub.io/pub

Then, add the SecretHub repo to /etc/apk/repositories:

echo "https://alpine.secrethub.io/alpine/edge/main" >> /etc/apk/repositories

Finally, you can install the CLI as any other apk package:

apk add --update secrethub-cli

First download the latest release.

To install, extract it to a directory of your choosing, for example:

mkdir -p /usr/local/secrethub
tar -C /usr/local/secrethub -xzf secrethub-vx.x.x-os-architecture.tar.gz

Note: depending on your OS configuration, you may need root priviliges to write to the /usr/local directory.

Ensure the binary is accessible by symlinking to it from a directory that is on your PATH environment variable, for example:

ln -s /usr/local/secrethub/bin/secrethub /usr/local/bin/secrethub

Windows

To install the CLI using Scoop, first add the SecretHub bucket:

scoop bucket add secrethub https://github.com/secrethub/scoop-secrethub

Afterwards, run this to actually install the CLI:

scoop install secrethub-cli

To download and install the secrethub CLI, run the following in Powershell as an Administrator:

iwr https://get.secrethub.io/windows | iex 

And you’re done.

Note: this works for Windows Server 2012 R2, Windows 8, and upwards. For older operating systems (e.g. Windows Server 2008 R2), use the equivalent more verbose command:

(New-Object System.Net.WebClient).DownloadString("https://get.secrethub.io/windows") | iex

Other

You can also choose to run the CLI as an isolated Docker container instead.

docker run -it -v $HOME/.secrethub:/root/.secrethub secrethub/cli

And optionally create an alias for it:

alias secrethub='docker run -it -v $HOME/.secrethub:/root/.secrethub secrethub/cli'

Note: some features of the CLI may not be available by default in Docker, like writing to the clipboard with the --clip flag or piping a secret to the write command.

We will add more package managers soon.

Some that are on our whishlist:

  • yum
  • apt-get
  • choco
  • pacman

Verify the CLI is correctly installed

To test your installation, run:

secrethub --version

If all went well, this should print out the version of the SecretHub CLI that was just installed.

Install auto-completion

To install auto-completion for the CLI, run one of the following commands depending on your shell of choice:

# Install bash completion
secrethub --completion-script-bash > /etc/bash_completion.d/secrethub
# Install zsh completion
secrethub --completion-script-zsh > ~/.zsh/completion/secrethub

Troubleshooting

If you run into issues, check out the troubleshooting section of the reference documentation.