This script intends to improve usability of 1Password CLI when working with multiple sessions and.or terminals
oplogin
oplogout
In the case you have multiple opened windows and you reauthenticate in one, you can simply run opup
to refresh your OP_
env variables.
1Password has a CLI that relies on environment variables to store some authentication secrets. The trouble comes that by nature environment variables are sticked to the terminal session where you create them. So each time, you launch a new terminal session or a new program using the environment variable you should auth first.
This script stores the authentication token encrypted on disk and source it automatically each time you launch a new terminal session.
To grab the auth variables in your shell scripts include that at the beginning of your scripts
. opsign.sh
eval $(get1PasswordSession)
This script will try to login on both on your 1Password team and on your personal 1Password account.
- gpg
- gpg-agent
- op CLI
- MY_GPG_PUBLIC_ID: the ID of your GPG public key (make it trusted to prevent confirmation)
- MY_GPG_PRIVATE_KEYGRIP: the key grip of your private key (to check if key is loaded in gnupg agent)
- OP_TEAM_SHORTHAND: the shorthand name of your 1Password team