When I received my new laptop at Hashicorp, I began personalising it as we all do. I used dotfiles to configure iTerm, and quickly pulled down Brew to get (almost) everything I needed installed.
As I contemplated putting them in, I realised that it would be a lot more secure and a lot more portable if these were stored in 1Password (my personal secrets manager of choice). Getting Familiar with the 1Password Schema. First up, I created a new 1Password entry, using the Password type. I called it “Environment Variables”. ITerm2 for better and more customizable terminal emulation - Choosy if you like to have multiple browsers for different purposes. Bitwarden instead of 1Password, because it's free and available everywhere. Swish instead of (or in addition to) Rectangle if you use a trackpad (which is the best and most ergonomic pointing device especially.
One of the first things I noticed that I didn’t have were the environment variables that normally read out of my bash profile. As I contemplated putting them in, I realised that it would be a lot more secure and a lot more portable if these were stored in 1Password (my personal secrets manager of choice).
- Sudolikeaboss - Get 1password access from iterm2 Go sudolikeaboss is a simple application that aims to make your life as a dev, ops, or just a random person who likes to ssh and sudo into boxes much, much easier by allowing you to access your 1password passwords on the terminal.
- Sudolikeaboss is a simple application that aims to make your life as a dev, ops, or just a random person who likes to ssh and sudo into boxes much, much easier by allowing you to access your 1password passwords on the terminal. All you need is iterm2, 1password.
Getting Familiar with the 1Password Schema
First up, I created a new 1Password entry, using the Password type. I called it “Environment Variables”.
I have put that entry into Edit mode in the image below so you can get a feel for the schema as it looks when you are setting this up in the UI.
I have put that entry into Edit mode in the image below so you can get a feel for the schema as it looks when you are setting this up in the UI.
I named the Section as Environment Variables also, and created entries where the Label value matched the name of the environment variable I wanted to set. The value is… the value. You should also note from the screenshot that you can set the value type - I used “password” throughout in this case.
Next up, I grabbed the 1Password CLI and configured it per the official docs.
Once you’ve completed the configuration, login using
Enter your master password, and if you’re using it your 2FA code.
eval $(op signin my)
Enter your master password, and if you’re using it your 2FA code.
Iterm2 1password Integration
Next up, you can run
op get item 'Environment Variables' | jq .
to get a better handle on the schema layout.You’ll note that the first section (
'.details.sections[0]
) actually contains the name and title of your entry. As you can see in the image below, the second entry contains the details that we want to make use of.The other thing that you’ll see here is that the key/value pair of the information that I’m after are represented by t and v respectively.
Iterm2 Password Manager
At this point, I thought I had enough of a handle on this to write it up as a bash script. The details of that are below.
Iterm2 1password App
To leverage this, simply
source ~/.import_envvars.sh
and away you go.