Created
March 2, 2022 04:01
-
-
Save t04glovern/a4e936edfc669eced7d6b4f5758f923c to your computer and use it in GitHub Desktop.
Windows Subsystem for Linux: never prompt ssh passphrase again
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
# Auto start keychain | |
eval $(/usr/bin/keychain --eval --quiet id_rsa) |
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
# Create an Task Scheduler event on login to run this powershell script | |
$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 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