Auto answer host key question in a script

Advertisement

silverfox
Joined:
Posts:
1
Location:
Atlanta, GA

Auto answer host key question in a script

I am trying to build a script so I can execute this under the task scheduler on the Windows server.
When I execute the open, winscp shows my the server fingerprint and then ask me if I trust this host enter 'Y'es,'N'o, C'a'ncel or 'C'opy and it automatically selects 'a' for cancel. How can I get the 'N' accepted or even skip over this question.
Authenticating...
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 49:f7:11:87:19:a4:9c:5d:9b:cc:88:34:40:ba:5b:87
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection
ss Cancel.
Continue connecting and add host key to the cache?
(Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel

Reply with quote

Advertisement

Guest

Re: auto answer host key question in a script

When looking at the open command in the docs, there is no "reply with quote". So just how do you solve the issue with having to put the certificate into the open command, when scripting?

Reply with quote

aja206
Guest

Documentation not clear

The documentation doesn't clearly show people how to use -certificate in conjunction with open to auto accept certificates...

I tried 4 variations so far and it does not work.

Here is your example arguments with scheduled tasks:
/log=c:\path\winscp.log /command "open sftp://user:password@example.com/" "put d:\examplefile.txt /home/user/" "exit"
Where do you plug -certificate?

Reply with quote

Advertisement

aja206
Guest

Okay here is how you do it

Okay I burned a brain and finger calories solving the puzzle and answer what others are looking for here.

You have to add -certificate=* at the end of the path after the open command so:
/log=c:\path\winscp.log /command "open sftp://user:password@example.com/ -certificate=*" "put d:\examplefile.txt /home/user/" "exit"

Reply with quote

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

Re: Okay here is how you do it

@aja206:
In general, easiest is to have WinSCP GUI generate the commandline for you:
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

Advertisement

You can post new topics in this forum