To automatically spawn an ssh-agent when starting the first Bash instance, and otherwise re-register a running ssh-agent in the Windows Subsystem for Linux, append the following lines to your .bashrc. Kudos to Mathew Johnson!
# wsfl bash is not a login shell if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi # ssh-agent configuration if [ -z "$(pgrep ssh-agent)" ]; then rm -rf /tmp/ssh-* eval $(ssh-agent -s) > /dev/null else export SSH_AGENT_PID=$(pgrep ssh-agent) export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name agent.*) fi if [ "$(ssh-add -l)" == "The agent has no identities." ]; then ssh-add fi