Windows Subsystem for Linux: never prompt your ssh passphrase again

How to configure a passphrase-less ssh setup for wsl — windows subsystem for linux —basing on keychain, credentials manager, task scheduler and a bunch of scripts.

Requirements

The scripts

$credentials = Get-StoredCredential -Target sshpassphrase                       $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credentials.Password)$passphrase = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)                       C:\Windows\System32\wsl.exe -u [YOUR_WSL_USERNAME] -d [YOUR_DISTRIBUTION] /home/[YOUR_WSL_USERNAME]/wslu/keychain.sh $passphrase
#!/bin/bash
SSH_ASKPASS_SCRIPT=/tmp/ssh-askpass-script
cat > ${SSH_ASKPASS_SCRIPT} <<EOL
#!/bin/bash
echo "$1"
EOL
chmod u+x ${SSH_ASKPASS_SCRIPT}
export DISPLAY="0"
export SSH_ASKPASS=${SSH_ASKPASS_SCRIPT}
/usr/bin/keychain --clear id_rsa
rm ${SSH_ASKPASS_SCRIPT}

Configuration

Conclusion

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store