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

Advertisement

Almir
Guest

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

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.
********************
Asking user:
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?
I already tried using the IP instead of host address but that didn't make any difference.

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
cd /upload
put D:\SFTP_ECHO\to_echo\p1789217184_Support*
# Disconnect
close
# Exit WinSCP
exit

Reply with quote

Advertisement

rkn
Guest

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\"


Please help me to fix this issue so that i can schedule this one. Appreciate your help.

Reply with quote

rkn
Guest

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.

Reply with quote

Almir
Guest

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?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

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\"

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

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.
Make sure you read:
https://winscp.net/eng/docs/faq_scheduler

Reply with quote

Appadu kumar
Joined:
Posts:
2

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) %

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

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

Appadu kumar wrote:

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

Reply with quote

Advertisement

Appadu kumar

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

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

Reply with quote

TonyRay
Guest

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.

Reply with quote

Advertisement

You can post new topics in this forum