Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

# Topic review

TonyRay

## This worked for me also

rkn wrote:

I solved the issue.

When I ran the script from the above post with admin account the "server's host key" stores in the cache and worked fine.

Even though I am the admin on the server I had to right click WINSCP and choose "run as admin". Then when I selected update the key it was the last time I got the pop up box.

After adding -hostkey we are getting "Too many parameters for Open command" error message. Any suggestions would be appreciated.
martin

## Re: The server's host key was not found in the cache

even we are getting the same error. Please help in resolving this, we are below command to connect to SFTP server.
%Chr(34) +"D:\Program Files (x86)\WinSCP\winscp.com" + Chr(34) + " /command " + Chr(34) + "open sftp://" + HOST_USERNAME + ":" + HOST_PASSWORD + "@" + SFTP_HOST + "/" + Chr(34) +" " + Chr(34)+ "put " + D:\Temp + log.txt +" "+ FOLDER_PATH_TO + Chr(34) + " " + Chr(34) +"exit"+ Chr(34) %

And the answer is still the same: use -hostkey switch:
https://winscp.net/eng/docs/scripting#hostkey

even we are getting the same error. Please help in resolving this, we are below command to connect to SFTP server.
%Chr(34) +"D:\Program Files (x86)\WinSCP\winscp.com" + Chr(34) + " /command " + Chr(34) + "open sftp://" + HOST_USERNAME + ":" + HOST_PASSWORD + "@" + SFTP_HOST + "/" + Chr(34) +" " + Chr(34)+ "put " + D:\Temp + log.txt +" "+ FOLDER_PATH_TO + Chr(34) + " " + Chr(34) +"exit"+ Chr(34) %
martin

## Re: The server's host key was not found in the cache.

Almir wrote:

I read the documentation and tried using a few different options yet i get the same warning error. If i execute manually it works fine. So i extracted the registry key and imported it to all users registry. It still doesn't work. I used the destination server's IP in the connect string and that didn't help either. My batch file calls the text file that holds the script code i posted above.

You have to import the settings to the account prive registry hive. WinSCP does not load these settings from all users registry.
https://winscp.net/eng/docs/faq_scheduler
martin

## Re: The server's host key was not found in the cache.

rkn wrote:

"winscp.exe" /console /command "option confirm off" "option batch continue" "open userid:pwd@abc.com" -hostkey="ssh-rsa 1111 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" "cd /out" "option transfer binary" "synchronize local \\abc\data\files\"

Actually correct syntax is:
"winscp.exe" /console /command "option confirm off" "option batch continue" "open userid:pwd@abc.com -hostkey=""ssh-rsa 1111 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" "cd /out" "option transfer binary" "synchronize local \\abc\data\files\"
Almir

## Re: The server's host key was not found in the cache.

I read the documentation and tried using a few different options yet i get the same warning error. If i execute manually it works fine. So i extracted the registry key and imported it to all users registry. It still doesn't work. I used the destination server's IP in the connect string and that didn't help either. My batch file calls the text file that holds the script code i posted above.

Any ideas?
rkn
I solved the issue.

When I ran the script from the above post with admin account the "server's host key" stores in the cache and worked fine.
rkn

## Re: The server's host key was not found in the cache.

martin wrote:

Hi,

I'm using the below script but it's always gives this error "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."

"winscp.exe" /console /command "option confirm off" "option batch continue" "open userid:pwd@abc.com" -hostkey="ssh-rsa 1111 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" "cd /out" "option transfer binary" "synchronize local \\abc\data\files\"

if i remove the "option batch continue" from the command then it's promting me to select
Yes, No, Cancle or Copy, if i choose manually Yes then it's working fine.

"winscp.exe" /console /command "option confirm off" "open userid:pwd@abc.com" -hostkey="ssh-rsa 1111 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" "cd /out" "option transfer binary" "synchronize local \\abc\data\files\"

martin

## Re: The server's host key was not found in the cache.

Almir

When i execute the batch file manually the remote server asked me to confirm the host key and add it in the cache. Once i did that it opened fine. When i schedule the batch file through SQL scheduled tasks it failes. It gives me the error that it waited for user input on the host confirmation.
********************
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 dss key fingerprint is:
ssh-dss 1234 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
Continue connecting and add host key to the cache? ()
*********************

Any ideas on how to get around this?

This is what i have in the script:
# Automatically answer all prompts negatively not to stall the script on errors
# option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
put D:\SFTP_ECHO\to_echo\p1789217184_Support*
# Disconnect
close
# Exit WinSCP
exit