Scripting Automation Does Not Work with SSH Keys

Advertisement

kooldrmony
Guest

Scripting Automation Does Not Work with SSH Keys

I have a working script that runs manually but will not run via the Task Scheduler nor will it work on a different environment (new user, new computer, etc.). I have tried to export and import the configurations from the working script/computer but it does not work. I have also tried importing the registry configurations from the working computer to the new computer, again it does not work. I have uninstalled and installed an old version of WinSCP to match the working one, and still it does not work. There are not any examples of how this is done. The documentation simply says to transfer the configuration to the new computer by exporting and importing the INI files and placing it in the same directory as the .exe file but that does not work. I am at a loss as to how this is not working anymore when it was previously at one point in time. I have attached the logs from the two machines for your review and also the win.com cmd that comes up for both so you can see that the working one does not ask for the password, it grants me access with ssh but the other non-working script asks for a password, which I do not have. Please help as the documentation on how to transfer configurations is not clear nor are there any examples as to how to accomplish this. I have tried everything I could but I am getting nowhere.

Please contact me regarding this issue at derrick.reyes@ieinstitute.net
Description: This is the cmd text that shows that UNLIKE the other cmd script this one asks for a password (which is not how I want it to work. I want it to use the SSH keys instead of ask for password).
Description: This is the log of the script/computer that is working
Description: This is the log of the computer where the script is not working.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: Scripting Automation Does Not Work with SSH Keys

When you run the script manually, it authenticates using a key loaded from Pageant. When the script is run in Task Scheduler, it run in a different Windows session, which cannot access the Pageant in your user session. And if you run the script on different machine, it cannot work at all.

You need to explicitly specify the key in your script. Use -privatekey switch:
https://winscp.net/eng/docs/scriptcommand_open#privatekey

See also https://winscp.net/eng/docs/faq_scheduler

Reply with quote

Advertisement

You can post new topics in this forum