I have an SSIS process task that is attempting to upload a file to an sftp site using WinSCP. The SSIS process task is calling WinSCP.exe with the /script argument. The script looks like this:
open sftp://test:password@10.187.1.130/
put C:\MyPath\MyFileName.c2t
exit
This all works fine even though there is no host key when I run the SSIS package in the development environment. When I run the SSIS package from within a SQL Agent Job, the job fails on the WinSCP task due to the lack of a host key. (Key values changed)
. 2018-12-10 22:08:51.632 Asking user:
. 2018-12-10 22:08:51.632 **Continue connecting to an unknown server and add its host key to a cache?**
. 2018-12-10 22:08:51.632
. 2018-12-10 22:08:51.632 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.
. 2018-12-10 22:08:51.632
. 2018-12-10 22:08:51.632 The server's RSA key details are:
. 2018-12-10 22:08:51.632
. 2018-12-10 22:08:51.632 Algorithm: ssh-rsa 2048
. 2018-12-10 22:08:51.632 SHA-256: QWg8xjMNHIMyKJC/oluxQPVnwaEGN1wgYHG5/gqrwaw=
. 2018-12-10 22:08:51.632 MD5: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
. 2018-12-10 22:08:51.632
. 2018-12-10 22:08:51.632 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
. 2018-12-10 22:08:51.632 In scripting, you should use a -hostkey switch to configure the expected host key. ()
. 2018-12-10 22:09:01.634 Attempt to close connection due to fatal exception:
* 2018-12-10 22:09:01.634 Host key fingerprint is ssh-rsa 2048 QWg8xjMNHIMyKJC/oluxQPVnwaEGN1wgYHG5/gqrwaw=.
* 2018-12-10 22:09:01.634 (Exception) **Host key wasn't verified!**
. 2018-12-10 22:09:01.634 Closing connection.