Skip to content

Instantly share code, notes, and snippets.

@chunter
Created June 20, 2017 10:51
Show Gist options
  • Save chunter/3ec25dd802c2163265eacfcb6f53cb7d to your computer and use it in GitHub Desktop.
Save chunter/3ec25dd802c2163265eacfcb6f53cb7d to your computer and use it in GitHub Desktop.
Make Pageant autoload keys at startup
To make Pageant automatically run and load keys at startup:
- Find the location of pageant.exe
- Windows key + R to open the 'run' dialog box
- Type: 'shell:startup' in the dialog box
- Create a shortcut to the pageant.exe and put into this startup folder.
- Right click on the shortcut and open 'Properties'
- In 'Target' add: "<route to>/pageant.exe" myprivatekeyname.ppk
- In 'Start in' add: "<route to myprivatekeyname.ppk>"
- Click on the shortcut link and check that Pageant has started and has loaded your keys
@7wells
Copy link

7wells commented Feb 21, 2024

Got it - indeed very promising. Meanwhile, I looked into this fork, which has several updates (not yet tested):
https://github.com/KerickHowlett/wsl2-ssh-bridge

EDIT1: I like Pageant, because it supports WinSCP, too, and I was not aware if there are alternatives for this, too.

EDIT2: Might be helpful, too:
https://gist.github.com/dinvlad/a62d44325fa2b989a046fe984a06e140

@strarsis
Copy link

strarsis commented Apr 9, 2024

You may also find this guide for setting up KeePass + KeeAgent for WSL 2 SSH interesting:
https://gist.github.com/strarsis/e533f4bca5ae158481bbe53185848d49

@jay-ramani
Copy link

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] "Pageant"="cmd /c "for %i in ("%USERPROFILE%\*.ppk") do start "%ProgramFiles%\PuTTY\pageant.exe" "%i"""

A variation of @xkolk approach above, but with support for loading multiple keys:

Use this on the command line, as a startup command in your registry, or from the command line (just the stuff between the first and last quotes):

cmd /V:ON /c "set keys= && (for %i in ("%PATH_TO_YOUR_PPK_FILES%\*.ppk") do (set keys=!keys! %i)) && start "" "C:\Program Files\PuTTY\pageant.exe" --encrypted !keys!"

The use of --encrypted will cause pageant to load without asking for any passwords. Then, on first use, it will ask for the password(s) and keep the keys decrypted in memory.

Very useful. Thank you both @xkolk and @brunokc.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment