Skip to content

Commit

Permalink
Install private SSH and GPG key from 1Password
Browse files Browse the repository at this point in the history
  • Loading branch information
pkissling committed Oct 26, 2023
1 parent 29269bf commit 717f2bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ git: bootstrap
@chmod +x git/install.sh
@./git/install.sh

gpg: bootstrap
gpg: bootstrap brew
@chmod +x gpg/install.sh
@./gpg/install.sh

Expand Down
10 changes: 10 additions & 0 deletions gpg/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ ln -sfv "${HOME}"/dotfiles/gpg/gpg-agent_"${USAGE}".conf "${HOME}"/.gnupg/gpg-ag
# import public gpg keys
gpg --import ~/dotfiles/gpg/private.asc
gpg --import ~/dotfiles/gpg/work.asc

# add private gpg key from 1password, if not exist
if [ -z "$(gpg --list-secret-keys)" ]; then
if [ "${USAGE}" = "work" ]; then
ONE_PASSWORD_DOCUMENT_ID="qoudpafw75h5i3lw7nyt67ewmq"
else
ONE_PASSWORD_DOCUMENT_ID="n5zwvjshndohrik5k7jrjktfxe"
fi
gpg --import <(op document get "${ONE_PASSWORD_DOCUMENT_ID}")
fi
13 changes: 13 additions & 0 deletions ssh/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ ln -sfv "${HOME}"/.ssh/"${USAGE}".priv "${HOME}"/.ssh/id_rsa

# create symlinks for config file
ln -sfv "${HOME}"/dotfiles/ssh/config "${HOME}"/.ssh

# add private ssh key from 1password, if not exist
if [ ! -f "${HOME}"/.ssh/"${USAGE}.priv" ]; then
if [ "${USAGE}" = "work" ]; then
ONE_PASSWORD_VAULT="Azena"
ONE_PASSWORD_KEY_ID="2vgwjhx6xauti4mpxiltsalzyy"
else
ONE_PASSWORD_VAULT="Personal"
ONE_PASSWORD_KEY_ID="2uc6ialn2lqxqlpitlil4howha"
fi
op read op://"${ONE_PASSWORD_VAULT}"/"${ONE_PASSWORD_KEY_ID}"/'private key' > "${HOME}"/.ssh/"${USAGE}.priv"
chmod 600 ~/.ssh/id_rsa
fi

0 comments on commit 717f2bd

Please sign in to comment.