Writing our first secrets

Now that we have a testing repository set up, we can start writing some secrets. Let’s start simple by running the following command and typing Hello World when prompted:

secrethub write $SH_USERNAME/testing/hello

As we can see, the secret hello is now written to SecretHub.

Because we know you love to script, secrethub write also accepts input on stdin.

If we now want to read our newly created secret, we can run:

secrethub read $SH_USERNAME/testing/hello

Pro tip: we can use SecretHub for passwords too

While SecretHub is mainly meant for infrastructure secrets, we often find it can be equally useful for managing our passwords. Whenever we want to generate a random password, we can use the secrethub generate command. The following line generates a random password of 22 characters for some example.com website:

secrethub generate rand $SH_USERNAME/testing/example.com

When we need to type in a password somewhere, we can use the secrethub read with the --clip flag. This copies the secret value to our clipboard for 45 seconds.

secrethub read --clip $SH_USERNAME/testing/example.com 

To read more on these commands, we can always use the secrethub <command> --help syntax.

Let’s move on to using secret versions.