Topic "The Server's host key was not found in cache"

Author Message
kmkrause2

Guest


WinSCP v. 4.3.2 build 1201
Windows Server Standard 2003 R2 SP2

When connecting to an SFTP server using the GUI Explorer interface, I can connect just fine. When I call an automated script from Windows Task Scheduler, I don't connect and the log file shows:

2011-09-27 15:06:04.479 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
. 2011-09-27 15:06:04.479
. 2011-09-27 15:06:04.479 Continue connecting and add host key to the cache? ()
. 2011-09-27 15:06:04.479 Attempt to close connection due to fatal exception:
* 2011-09-27 15:06:04.479 Host key wasn't verified!
. 2011-09-27 15:06:04.479 Closing connection.
. 2011-09-27 15:06:04.479 Sending special code: 12

My script file is:

@echo off
option batch on
option confirm off
open sftp://<username>:<password>@<host>.<domain>.com:228
cd /incoming
put d:\test file.txt
close

If I run the same script commands manually from a CLI, I can also connect and I never get propmted to accept the server key. How can I resolve this?

Thanks,
Ken
Advertisements
kmkrause2

Guest


Nevermind... I found the solution in a few other forum posts.

Very Happy
Guest




kmkrause2 wrote:
Nevermind... I found the solution in a few other forum posts.

Very Happy


Here's the link to the forum post that helped me resolve the issue.
https://winscp.net/eng/docs/config#registry_key

I used the registry method. My scheduled task was running under anohter AD account created just for services and scheduled tasks. I connected to the SFTP server using the GUI under my account, which logged the key from the server in the registry. I then copied the registry key mentioned in the link to the other accounts user area in the registry. I could have also logged into the server under the other account and used the GUI to connect. This would have also stored the server key in the registry.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
This may be better link:
https://winscp.net/eng/docs/scripting#hostkey
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License