我创建了这个批处理来使用SSH密钥传输文件,我检查了两个服务器上的公钥和私钥映射,并且它运行良好。
使用SFTP命令的Windows批处理代码如下:
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命令,但说“未知命令”。建议是最受欢迎的。
我想要做的事情,像这个链接"WinSCP“通过WinSCP命令,但在我的Windows自动验证主机。
发布于 2021-03-23 07:12:57
若要在WinSCP脚本中验证主机密钥,请添加命令
open sftp://sftp_user@ssh_dest_server -hostkey=... -privatekey="D:\directory_full_path\private_key.ppk" -rawsettings TryAgent=0 AuthKI=0 AuthGSSAPI=0
请参阅验证主机密钥..。在剧本中文档中的WinSCP文档。它涵盖了你需要知道的一切。特别是获取主机键值的位置。
还请注意,即使使用WinSCP开关,-hostkey
GUI也可以为您提供生成脚本模板。
也包括在我的脚本在手动执行时运行良好,但在Windows Scheduler、SSIS或其他自动化服务运行时会失败或挂起。我做错了什么?中
https://stackoverflow.com/questions/66758132
复制相似问题