Update README.md

This commit is contained in:
2022-10-13 16:53:28 -04:00
committed by GitHub
parent 4c2ab50af7
commit 1d102af0ec

View File

@@ -30,6 +30,43 @@ mkdir -p ~/bin
chmod +x ~/bin/npiperelay.exe
mkdir -p $HOME/.ssh
touch $HOME/.ssh/agent.sock
'''
## Create
```
GNU nano 6.3 /home/sstent/bin/wsl-ssh-agent-forwarder #!/usr/bin/env bash
# Usage: wsl-ssh-agent-forward [ -k | -r ]
# Options:
# -k Kill the current process (if exists) and do not restart it.
# -r Kill the current process (if exists) and restart it.
# Default operation is to start a process only if it does not exist.
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
sshpid=$(ss -ap | grep "$SSH_AUTH_SOCK")
if [ "$1" = "-k" ] || [ "$1" = "-r" ]; then
sshpid=${sshpid//*pid=/}
sshpid=${sshpid%%,*}
if [ -n "${sshpid}" ]; then
kill "${sshpid}"
else
echo "'socat' not found or PID not found"
fi
if [ "$1" = "-k" ]; then
exit
fi
unset sshpid
fi
if [ -z "${sshpid}" ]; then
rm -f $SSH_AUTH_SOCK
( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/de>fi
```
## Enable the forwarder
```
. ~/bin/wsl-ssh-agent-forwarder
ssh-add -l
exit