Skip to content

Instantly share code, notes, and snippets.

@patrick330602
Created May 12, 2020 03:42
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 patrick330602/3908a7ef074c1154891de8dc217f17e0 to your computer and use it in GitHub Desktop.
Save patrick330602/3908a7ef074c1154891de8dc217f17e0 to your computer and use it in GitHub Desktop.
gpg-forward for wsl
#!/bin/bash
if [ ! -S "$HOME/.gnupg/S.gpg-agent" ]
then
GPG_AGENT="/mnt/c/Users/csl/AppData/Roaming/gnupg/S.gpg-agent.extra"
PREPEND_FILE="/tmp/gpg_agent_prepend"
WINDOWS_GPG_AGENT_PORT=$(head -n1 "$GPG_AGENT")
tail -n+2 "$GPG_AGENT" > "$PREPEND_FILE"
socat "UNIX-LISTEN:$HOME/.gnupg/S.gpg-agent,fork" \
"SYSTEM:cat \"$PREPEND_FILE\" - <&3 | socat STDIO \"TCP\:127.0.0.1\:$WINDOWS_GPG_AGENT_PORT\" >&4,fdin=3,fdout=4"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment