windowspowershellsshssh-keyspageant

Start Pageant SSH-Agent and load all keys in a folder


How can i start the pageant ssh agent, and load all my private keys without adding them one by one to a batch file or in pageant itself?

I can add key-files to pageant on the commandline by listing them after the executable or load them manually when pageant is already running. But there is no well documented way to load all the key-files in a folder on startup.


Solution

  • i assume you have putty and thus pageant installed and available in your PATH

    1. add a shortcut in you windows autostart menu: C:\Users\[USER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
    2. edit the shortcut and enter powershell -Command "& pageant (Get-ChildItem [PATH TO KEYS]\*.ppk)" (preplace [PATH TO KEYS] with the path to your key-files ;)
    3. (optional) update the image of the shortcut to anything more appropriate
    4. click ok.

    On the next reboot pageant should be started up with all the ppk files in the linked folder.

    If you want to avoid the console window popup, get RunHiddenConsole from https://github.com/SeidChr/RunHiddenConsole.

    1. rename the hiddenw.exe to powershellw.exe or pwshw.exe (whatever shell you are using) and put the file in a folder that is listed in your PATH
    2. update the shortcut to powershellw -Command "& pageant (Get-ChildItem [PATH TO KEYS]\*.ppk)"
    3. click ok