Skip to content

Instantly share code, notes, and snippets.

@ismet55555
Created January 27, 2023 04:12
Show Gist options
  • Save ismet55555/3be1442505523d0ead85c887bc807dfb to your computer and use it in GitHub Desktop.
Save ismet55555/3be1442505523d0ead85c887bc807dfb to your computer and use it in GitHub Desktop.
How to install, setup, and use 1Password CLI on Linux

1Password CLI

General info: https://developer.1password.com/docs/cli

Install and Setup

Release Versions: https://app-updates.agilebits.com/product_history/CLI2

OP_VERSION="v2.13.1"

# Download and Install
curl -sSfo op.zip https://cache.agilebits.com/dist/1P/op2/pkg/${OP_VERSION}/op_linux_amd64_${OP_VERSION}.zip
sudo unzip -od /usr/local/bin/ op.zip
rm op.zip

# Add correct permissions
sudo groupadd onepassword-cli
sudo chown root:onepassword-cli /usr/local/bin/op
sudo chmod g+s /usr/local/bin/op

Add Account and Sign In

Find Secret Key: https://support.1password.com/secret-key

OP_ACCOUNT_ADDRESS="https://XXXXXX.1password.com/"
OP_ACCOUNT_EMAIL="USERNAME@DOMAIN.com"
OP_ACCOUNT_SECRET_KEY="A3-..."
OP_ACCOUNT_SHORTHAND="my_account"

op account add \
    --shorthand "${OP_ACCOUNT_SHORTHAND}" \
    --address "${OP_ACCOUNT_ADDRESS}" \
    --email "${OP_ACCOUNT_EMAIL}" \
    --secret-key "${OP_ACCOUNT_SECRET_KEY}"
OP_ACCOUNT_PASSWORD="<YOUR PASSWORD>"

eval $(printf "${OP_ACCOUNT_PASSWORD}\n" | op signin --account ${OP_ACCOUNT_SHORTHAND})

Basic Usage

More info: https://developer.1password.com/docs/cli/get-started#usage

# List all vault secrets
op items list

# Get some login password
op item get "My Secret Something" --fields password

# Take a template file, add credentials, and make config file
op inject -i config.yml.tpl -o config.yml

Sign out

op signout --account ${OP_ACCOUNT_SHORTHAND}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment