I'm trying to create simple Windows batch script that will manage connectivity to our client. That includes some tunnels using plink.exe
and socks chain. Each hop requires ssh key authentication for which I'm using pageant.exe
.
I have each piece scripted out as needed, except the pageant part, where I struggle. Facts encountered:
If I only start pageant.exe
it will start pageant agent without any SSH key loaded and script will continue right away. Then I can run pageant.exe my_key.ppk
to add the key into pageant and passphrase will be prompted, however script will continue meanwhile as well, so script will continue to plink part which will fail, because user will not provide passphrase till that time.
I've been looking into pageant docs and found some CLI switches like -l
that supposedly should list loaded keys, that however does not seems to work on Windows version. Seems like windows version is only accepting arguments in form of .ppk files
I'd like to basically make some kind of "wait" function until user will provide passphrase. Is there any way how to either list loaded keys directly from pageant or any generic method asking Windows environment for SSH keys?
Pageant has
-c
switch, which you can use to pass a command to be executed after a private key is loaded:Though in general Pageant is a tool for an interactive use, not for scripting. For scripting, use
-i
switch of Plink to provide a private key for authentication.