Skip to content

Instantly share code, notes, and snippets.

@tstachl
Last active October 12, 2022 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstachl/0db5a09921d5513c8d62c83b73550c30 to your computer and use it in GitHub Desktop.
Save tstachl/0db5a09921d5513c8d62c83b73550c30 to your computer and use it in GitHub Desktop.
This bash script enables GPG, Yubikey and SSH on a nixos live cd for my public key.
#!/run/current-system/sw/bin/sh
nix-env -iA nixos.git nixos.gnupg nixos.pinentry-curses
gpg --receive-keys DE749C31D060A160
echo "$( \
gpg --list-keys \
| grep DE749C31D060A160 -A 1 \
| head -1 | tr -d '[:space:]' \
):6:" | gpg --import-ownertrust;
echo "pinentry-program $(which pinentry)" > ~/.gnupg/gpg-agent.conf
gpg-connect-agent reloadagent /bye
echo "export SSH_AUTH_SOCK=\$(gpgconf --list-dirs agent-ssh-socket)" >> ~/.bashrc
echo "export PINENTRY_USER_DATA=\"USE_CURSES=1\"" >> ~/.bashrc
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
source ~/.bashrc
gpg-connect-agent updatestartuptty /bye
echo "DONE."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment