Last active
May 23, 2022 05:23
-
-
Save glsorre/4c2fa9eb237fc07e1321f0ff6a267067 to your computer and use it in GitHub Desktop.
Windows Subsystem for Linux: never prompt ssh passphrase again
This file contains hidden or 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
$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 |
This file contains hidden or 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/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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment