start: forward SSH agent requests from WSL to Windows
Instruction that I followed: https://stuartleeks.com/posts/wsl-ssh-key-forward-to-windows/ Using this tool to make Windows named pipes available in WSL: https://github.com/jstarks/npiperelay
This commit is contained in:
parent
aa0db16116
commit
d8b60916ef
2 changed files with 47 additions and 1 deletions
BIN
utils/bin/npiperelay
Normal file
BIN
utils/bin/npiperelay
Normal file
Binary file not shown.
|
@ -1,3 +1,49 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec ssh-agent tmux new-session -A -t main "$@"
|
usage () {
|
||||||
|
echo "usage: $0 [-w] [-h]"
|
||||||
|
echo " -w use the WSL ssh-agent instead of OpenSSH for Windows"
|
||||||
|
echo " -h show help and exit"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use OpenSSH for Windows by default.
|
||||||
|
WSL_SSH_AGENT=false
|
||||||
|
|
||||||
|
while getopts ":wh" arg; do
|
||||||
|
case "$arg" in
|
||||||
|
w)
|
||||||
|
WSL_SSH_AGENT=true
|
||||||
|
;;
|
||||||
|
|
||||||
|
h)
|
||||||
|
>&2 usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
?)
|
||||||
|
>&2 echo "ERROR: unknown option -$OPTARG"
|
||||||
|
>&2 usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$WSL_SSH_AGENT" = true ]; then
|
||||||
|
exec ssh-agent tmux new-session -A -t main "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
require() {
|
||||||
|
if ! command -v "$@" >/dev/null 2>&1; then
|
||||||
|
>&2 echo "ERROR: required command not found: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
require socat
|
||||||
|
require npiperelay
|
||||||
|
|
||||||
|
# Forward SSH Agent requests from withitn WSL to OpenSSH for Windows, based on:
|
||||||
|
# https://stuartleeks.com/posts/wsl-ssh-key-forward-to-windows/
|
||||||
|
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
|
||||||
|
socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay -ei -s //./pipe/openssh-ssh-agent",nofork &
|
||||||
|
exec tmux new-session -A -t main "$@"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue