In MS Windows, I am using the authentication agent „pageant“ (part of PuTTY) to read in my private key (a file with the ending .ppk, generated with „puttygen“) once and then use it for all subsequent SSH connections with „putty“. I would like to automate this task, executing the key-adding to „pageant“ once, right after I have logged in.
To do so, I put a copy of „pageant.exe“, my keypair „linuxfoo“ and „linuxfoo.ppk“ and the following script, „linuxfoo.vbs“ into a folder of my linking, for example „C:\Users\<me>\ssh\linuxfoo.vbs“:
Rem 1: Determine the script's containing directory:
Set s = CreateObject("WScript.Shell")
c = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
Rem 2: Run "pageant.exe my.ppk" from that directory:
cmd = """" & c & "pageant.exe" & """" & " " & """" & c & "linuxfoo.ppk" & """"
s.Run cmd
Now I can symlink „linuxfoo.vbs“ into my Autostart-folder and I get presented with the pageant-key-adding dialog right after I logged in.