From 25c08c9a30a0c28964e22dafa00ac3ab80a601eb Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Sun, 29 Oct 2023 21:33:06 +0100 Subject: [PATCH] SSH login via GPG authentication subkey --- .gnupg/gpg-agent.conf | 1 + .gnupg/sshcontrol | 3 ++- .zshrc | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gnupg/gpg-agent.conf b/.gnupg/gpg-agent.conf index 152ea2f..00851fa 100644 --- a/.gnupg/gpg-agent.conf +++ b/.gnupg/gpg-agent.conf @@ -1,3 +1,4 @@ enable-ssh-support default-cache-ttl 3600 max-cache-ttl 7200 +pinentry-program /usr/bin/pinentry-curses diff --git a/.gnupg/sshcontrol b/.gnupg/sshcontrol index a19e9f8..b137079 100644 --- a/.gnupg/sshcontrol +++ b/.gnupg/sshcontrol @@ -1 +1,2 @@ -8870E499C64EEB7720EBA5A442F4FE90129BFAE3 \ No newline at end of file +8870E499C64EEB7720EBA5A442F4FE90129BFAE3 + diff --git a/.zshrc b/.zshrc index 5d255e1..dfbfd1e 100644 --- a/.zshrc +++ b/.zshrc @@ -79,8 +79,16 @@ alias lt='ls -lath' alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' config config --local status.showUntrackedFiles no -# GPG with SSH auth capabilities -export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) +unset SSH_AGENT_PID +if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" +fi +export GPG_TTY=$(tty) +gpg-connect-agent updatestartuptty /bye >/dev/null + +export KEYGRIP=8870E499C64EEB7720EBA5A442F4FE90129BFAE3 +# Sometimes gpg has a bug and needs to re-import key +alias gbye='gpg-connect-agent "delete_key $KEYGRIP" /bye' if [ -f ~/.aliases ]; then . ~/.aliases