Skip to content

Instantly share code, notes, and snippets.

@krishna1306
Last active August 12, 2023 02:37
Show Gist options
  • Save krishna1306/efb19637e883eb62975728b36e4bb566 to your computer and use it in GitHub Desktop.
Save krishna1306/efb19637e883eb62975728b36e4bb566 to your computer and use it in GitHub Desktop.
Using `pass` utility on Mac

Remove the password line when using pass command

Add the below line(s) to ~/.zshrc

# function to remove first line of pass output
passp() { command pass "$@" | tail -n +2 }

Using pass utility on Mac

brew install pass

Create the keys using GPG

# Generate the key pair
gpg --gen-key

# List the keys generated
gpg -K

# Edit the Key and remove expiry date.
# Also trust the key (use '5')
gpg --edit-key <id>
> expire
> trust
> save

Using pass utility

# Password Store. Use the public key generated by GPG in the earlier step
pass init <id>

pass git init

# add password
pass insert <name>
# ass password value

# generate password
pass generate aws

# create passwords with namespace
pass generate github/personal

# look for a password
pass find github

# see all passwords
pass

# see password
pass show github

# don't display. just copy to clipboard
pass show -c github

# add metadata
pass edit github

# use meta-data to search
pass grep "info@email.com"
pass grep "email:"

# delete password
pass rm github

# undo previous change. undo previous commit
pass git revert HEAD

# set up git remote
pass git remote add origin <repo-link.git>

# push to remote
pass git push origin main

# clone password store
pass git clone <repo-link.git>

Prepare Keys for Exporting

mkdir exported-keys
cd exported-keys

# email serves as the GPG key's ID (instead of actual ID)
# 'public.gpg' is the file that will contai public key after this command is run
# 'armor' refers to base64 format
gpg --output public.gpg --armor --export info@email.com

# export private key
gpg --output private.gpg --armor --export-secret-key info@email.com

Import the keys into a new computer

gpg --import private.gpg
gpg --import public.gpg

Increase the trust level of the public key

gpg --edit-key info@email.com
> trust
# assign '5' -> high trust
> save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment