我正在尝试使用带有以下命令行参数的SSIS执行过程任务建立SFTP连接。
/log=G:\USER_DATA\USER_USER_SYNC\SFTP_LOG\user_sync_winscp.log /command "open sftp://username:[email protected]/" "get /DATA/UserRoleUpdate.csv G:\USER_DATA\USER_USER_SYNC\Download\" "exit"
给定的执行过程任务使用WinSCP exe将文件下载到本地驱动器。程序包在调试模式下以及在通过SQL Server的SSISDB文件夹手动运行时都成功运行。
尝试使用作业代理执行SSIS包时,我们遇到了一个问题。
如果我禁用了建立SFTP连接的特定任务,则程序包也将通过作业代理成功运行。似乎只有该特定任务有问题。
我正在努力了解为什么会发生这种情况以及需要采取哪些措施来解决此问题。
当我检查
user_sync_winscp.log
文件时,我发现了这一点。. 2019-08-20 08:10:23.931 Host key fingerprint is:
. 2019-08-20 08:10:23.931 ssh-rsa 2048 9b:63:5e:c4:26:bb:35:0d:49:e6:74:5e:5a:48:c0:8a bLgYggTcP4U6A/IFkFoyfY8BhlCB/+i5fFhzq1z1MjQ=
. 2019-08-20 08:10:23.931 Asking user:
. 2019-08-20 08:10:23.931 **Continue connecting to an unknown server and add its host key to a cache?** . 2019-08-20 08:10:23.931 . 2019-08-20 08:10:23.931 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.
. 2019-08-20 08:10:23.931
. 2019-08-20 08:10:23.931 The server's RSA key details are:
. 2019-08-20 08:10:23.931
. 2019-08-20 08:10:23.931 Algorithm: ssh-rsa 2048
. 2019-08-20 08:10:23.931 SHA-256: bLgYggTcP4U6A/IFkFoyfY8BhlCB/+i5fFhzq1z1MjQ=
. 2019-08-20 08:10:23.931 MD5: 9b:63:5e:c4:26:bb:35:0d:49:e6:74:5e:5a:48:c0:8a
. 2019-08-20 08:10:23.931
. 2019-08-20 08:10:23.931 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
. 2019-08-20 08:10:23.931 In scripting, you should use a -hostkey switch to configure the expected host key. () . 2019-08-20 08:10:33.933 Attempt to close connection due to fatal exception:
* 2019-08-20 08:10:33.933 Host key fingerprint is ssh-rsa 2048 bLgYggTcP4U6A/IFkFoyfY8BhlCB/+i5fFhzq1z1MjQ=.
* 2019-08-20 08:10:33.933 (Exception) **Host key wasn't verified!** . 2019-08-20 08:10:33.933 Closing connection.
. 2019-08-20 08:10:33.933 Sending special code: 12
然后,我从日志文件中复制了主机密钥,并通过添加一个
-hostkey="..."
开关更改了命令行参数,如下所示。/log=G:\USER_DATA\USER_USER_SYNC\SFTP_LOG\user_sync_winscp.log /command "open sftp://username:[email protected]/" -hostkey="ssh-rsa 2048 9b:63:5e:c4:26:bb:35:0d:49:e6:74:5e:5a:48:c0:8a" "get /DATA/UserRoleUpdate.csv G:\USER_DATA\USER_USER_SYNC\Download\" "exit"
现在,任务本身在本地失败。
请让我知道,以防需要添加更多详细信息。谢谢
最佳答案
正确的语法是:
... /command "open sftp://username:[email protected]/ -hostkey=""ssh-rsa 2048 9b:63:5e:c4:26:bb:35:0d:49:e6:74:5e:5a:48:c0:8a""" "get ..." ...
请参见WinSCP command-line syntax和
open
command syntax。WinSCP GUI可以为您提供generate a correct script/command-line,包括
-hostkey
switch。关于ssis - 尽管已将-hostkey开关添加到WinSCP命令行,但“Host key wasn't已验证”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57587270/