this repo has no description
dotfiles

Add files for WSL GPG forwarding

+52 -3
+32
bin/wsl-gpg-agent-relay.sh
··· 1 + #!/bin/bash 2 + # Launches socat+npiperelay to relay the gpg-agent socket file for use in WSL 3 + # See https://justyn.io/blog/using-a-yubikey-for-gpg-in-windows-10-wsl-windows-subsystem-for-linux/ for details 4 + 5 + GPGDIR="${HOME}/.gnupg" 6 + WINDOWS_USERNAME=adamh 7 + WSL_USERNAME=sharparam 8 + WIN_GPGDIR="C:/Users/${WINDOWS_USERNAME}/AppData/Roaming/gnupg" 9 + NPIPERELAY="/mnt/e/apps/npiperelay.exe" 10 + PIDFILE="${GPGDIR}/.gpg-agent-relay.pid" 11 + OLDPID=$(cat "${PIDFILE}" 2>/dev/null) 12 + 13 + # Launch socat+npiperelay for the regular gpg-agent 14 + if [ ! -z "${OLDPID}" ]; then 15 + ps -p "${OLDPID}" >/dev/null && \ 16 + echo "gpg-agent-relay.sh already running with process id $(cat ${PIDFILE})" && \ 17 + exit 0 18 + fi 19 + 20 + rm -f "${GPGDIR}/S.gpg-agent*" 21 + echo $$ > ${PIDFILE} 22 + 23 + # Relay the regular gpg-agent socket for gpg operations 24 + socat UNIX-LISTEN:"${GPGDIR}/S.gpg-agent,fork" EXEC:"${NPIPERELAY} -ep -ei -s -a '${WIN_GPGDIR}/S.gpg-agent'",nofork & 25 + AGENTPID=$! 26 + 27 + # Relay the gpg ssh-agent 28 + socat UNIX-LISTEN:"${GPGDIR}/S.gpg-agent.ssh,fork" EXEC:"${NPIPERELAY} -ep -ei -s -a '${WIN_GPGDIR}/S.gpg-agent.ssh'",nofork & 29 + SSHPID=$! 30 + 31 + wait ${AGENTPID} 32 + wait ${SSHPID}
+20 -3
zsh/.zshrc
··· 196 196 fi 197 197 198 198 export GPG_TTY="$(tty)" 199 - unset SSH_AGENT_PID 200 - export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) 201 - gpgconf --launch gpg-agent 199 + if [[ $is_wsl ]]; then 200 + wsl_gpg_agent_relay="$HOME/.local/bin/wsl-gpg-agent-relay.sh" 201 + if [[ -f "$wsl_gpg_agent_relay" ]]; then 202 + echo '[WSL] Launching WSL GPG agent relay' 203 + $wsl_gpg_agent_relay & 204 + else 205 + echo "[WSL] Missing: ${wsl_gpg_agent_relay}" 206 + fi 207 + unset SSH_AGENT_PID 208 + export SSH_AUTH_SOCK=$HOME/.local/wsl-ssh-pageant/ssh-agent.sock 209 + else 210 + unset SSH_AGENT_PID 211 + export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) 212 + gpgconf --launch gpg-agent 213 + fi 214 + 215 + if [[ -d '/usr/local/go/bin' ]]; then 216 + path=("$path[@]" /usr/local/go/bin) 217 + fi 218 + #export GOPATH="$HOME/go" 202 219 203 220 # tmux helpers 204 221 ts() {