SFTP 文件传输错误 - 连接到未知服务器并添加其主机密钥
SFTP file transfer error - connecting to an unknown server and add its host key
我已经创建了使用 SSH 密钥传输文件的批处理,我检查了两台服务器上的 public 和私钥映射,它工作正常。
我的Windows批处理代码使用SFTP命令如下:
open sftp://sftp_user@ssh_dest_server -privatekey="D:\directory_full_path\private_key.ppk" -rawsettings TryAgent=0 AuthKI=0 AuthGSSAPI=0
CD "/XYZ_Directory/folder1"
Put "\full_directory_path\FILE1.zip"
exit
当我手动执行批处理时,它执行得很好,没有任何问题,但是当我从 SQL 作业(使用不同的用户)执行批处理时,它会显示以下错误:
Searching for host...
Connecting to host...
Authenticating...
Continue connecting to an unknown server and add its host key to a cache?
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 RSA key details are:
Algorithm: ssh-rsa 2048
SHA-256: finger_print_key
MD5: zz:xx:yy:xx:yy:xx:yy:xx:yy:xx:yy:xx:yy:zz:zz:00
If you trust this host,
press Yes. To connect without adding host key to the cache,
press No. To abandon the connection press Cancel.
In scripting, you should use a -hostkey switch to configure the expected host key.
(Y)es, (N)o, C(a)ncel (10 s), (C)opy Key, (P)aste key: Cancel
Host key wasn't verified!
Host key fingerprint is ssh-rsa 2048 finger_print_key.
Authentication failed.
我已经尝试过 -hostkey
WinSCP 命令,但显示 “未知命令”。欢迎提出建议。
我想这样做 link “WinSCP” 通过 WinSCP 命令,但在我的 Windows 批处理中自动验证主机。
要在 WinSCP 脚本中验证主机密钥,请添加 -hostkey
switch to the open
command:
open sftp://sftp_user@ssh_dest_server -hostkey=... -privatekey="D:\directory_full_path\private_key.ppk" -rawsettings TryAgent=0 AuthKI=0 AuthGSSAPI=0
参见 Verifying the host key ... in script in WinSCP documentation. It covers everything you need to know. In particular, where to get the host key value。
另请注意,即使使用 -hostkey
开关,WinSCP GUI 也可以 generate a script template。
中介绍
我已经创建了使用 SSH 密钥传输文件的批处理,我检查了两台服务器上的 public 和私钥映射,它工作正常。
我的Windows批处理代码使用SFTP命令如下:
open sftp://sftp_user@ssh_dest_server -privatekey="D:\directory_full_path\private_key.ppk" -rawsettings TryAgent=0 AuthKI=0 AuthGSSAPI=0
CD "/XYZ_Directory/folder1"
Put "\full_directory_path\FILE1.zip"
exit
当我手动执行批处理时,它执行得很好,没有任何问题,但是当我从 SQL 作业(使用不同的用户)执行批处理时,它会显示以下错误:
Searching for host...
Connecting to host...
Authenticating...
Continue connecting to an unknown server and add its host key to a cache?
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 RSA key details are:
Algorithm: ssh-rsa 2048
SHA-256: finger_print_key
MD5: zz:xx:yy:xx:yy:xx:yy:xx:yy:xx:yy:xx:yy:zz:zz:00
If you trust this host,
press Yes. To connect without adding host key to the cache,
press No. To abandon the connection press Cancel.
In scripting, you should use a -hostkey switch to configure the expected host key.
(Y)es, (N)o, C(a)ncel (10 s), (C)opy Key, (P)aste key: Cancel
Host key wasn't verified!
Host key fingerprint is ssh-rsa 2048 finger_print_key.
Authentication failed.
我已经尝试过 -hostkey
WinSCP 命令,但显示 “未知命令”。欢迎提出建议。
我想这样做 link “WinSCP” 通过 WinSCP 命令,但在我的 Windows 批处理中自动验证主机。
要在 WinSCP 脚本中验证主机密钥,请添加 -hostkey
switch to the open
command:
open sftp://sftp_user@ssh_dest_server -hostkey=... -privatekey="D:\directory_full_path\private_key.ppk" -rawsettings TryAgent=0 AuthKI=0 AuthGSSAPI=0
参见 Verifying the host key ... in script in WinSCP documentation. It covers everything you need to know. In particular, where to get the host key value。
另请注意,即使使用 -hostkey
开关,WinSCP GUI 也可以 generate a script template。