Forum Discussion
Former Member
4 years agoHey Tristan!
I was actually working on this myself tonight, here's what I did.
OS: Windows 11 21H2
WSL 2 Ubuntu 20.04.3 LTS
Big big big shoutout to https://1password.community/discussion/comment/629936
- Enable 1Password SSH as defined here for WINDOWS: https://developer.1password.com/docs/ssh/get-started#step-3-turn-on-the-1password-ssh-agent
- Install the .exe https://github.com/jstarks/npiperelay somewhere where your Windows PATH can see it (make sure it's accessible from ubuntu and powershell, might need to restart Windows Terminal completely)
- Update your .bashrc or .zshrc in ubuntu with:
# Configure ssh forwarding export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock # need `ps -ww` to get non-truncated command for matching # use square brackets to generate a regex match for the process we want but that doesn't match the grep command running it! ALREADY_RUNNING=$(ps -auxww | grep -q "
piperelay.exe -ei -s //./pipe/openssh-ssh-agent"; echo $?) if [[ $ALREADY_RUNNING != "0" ]]; then if [[ -S $SSH_AUTH_SOCK ]]; then # not expecting the socket to exist as the forwarding command isn't running (http://www.tldp.org/LDP/abs/html/fto.html) echo "removing previous socket..." rm $SSH_AUTH_SOCK fi echo "Starting SSH-Agent relay..." # setsid to force new session to keep running # set socat to listen on $SSH_AUTH_SOCK and forward to npiperelay which then forwards to openssh-ssh-agent on windows (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1 fi - Restart the ubuntu terminal / resource the rc file.
- Test with
ssh-add -l
Should see your 1password ssh keys
From here Git and SSH in your Ubuntu instance should default to the 1password ssh-agent, with fallback to id_rsa (or whatever is configured in ur /etc/ssh config file.
Hope this helps!!
Matt