尽管在WinSCP命令行中添加了-hostkey开关,但“主机密钥尚未验证”

时间:2019-08-21 08:17:13

标签: ssis sftp winscp

我正在尝试使用具有以下命令行参数的SSIS执行过程任务建立SFTP连接。

/log=G:\USER_DATA\USER_USER_SYNC\SFTP_LOG\user_sync_winscp.log /command "open sftp://username:password@stransfer.host.com/" "get /DATA/UserRoleUpdate.csv G:\USER_DATA\USER_USER_SYNC\Download\" "exit"

给定的执行过程任务使用WinSCP exe将文件下载到本地驱动器。程序包在调试模式下以及在我通过SQL服务器上的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:password@stransfer.host.com/" -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"

现在,任务本身在本地失败。

请让我知道,以防需要添加更多详细信息。谢谢

1 个答案:

答案 0 :(得分:1)

正确的语法是:

... /command "open sftp://username:password@stransfer.host.com/ -hostkey=""ssh-rsa 2048 9b:63:5e:c4:26:bb:35:0d:49:e6:74:5e:5a:48:c0:8a""" "get ..." ...

请参见WinSCP command-line syntaxopen command syntax


WinSCP GUI可以generate a correct script/command-line为您服务,包括-hostkey switch