Last active
June 3, 2024 14:37
-
-
Save riedel/2002835932b073cea836fb171aa27a51 to your computer and use it in GitHub Desktop.
Bridge Windows 10 buildin OpenSSH agent to cygwin using socat and putty plink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SOCKDIR=`mktemp.exe -d /tmp/ssh-XXXXXXXXX` | |
SSH_AUTH_SOCK=$SOCKDIR/agent.$$;export SSH_AUTH_SOCK; | |
[ -z ${1+x} ] && echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK;export SSH_AUTH_SOCK;" | |
socat UNIX-LISTEN:$SSH_AUTH_SOCK,umask=066,fork EXEC:"PLINK.EXE -serial //./pipe/openssh-ssh-agent",pipes & | |
SSH_AGENT_PID=$!; export SSH_AGENT_PID; | |
if [ -z ${1+x} ]; then | |
(tail --pid $SSH_AGENT_PID -f /dev/null; rm -r $SOCKDIR) & | |
echo "SSH_AGENT_PID=$SSH_AGENT_PID; export SSH_AGENT_PID;" | |
echo "echo Agent pid $SSH_AGENT_PID;" | |
else | |
(tail --pid $$ -f /dev/null; kill $SSH_AGENT_PID; rm -r $SOCKDIR) & | |
exec $*; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment