首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SFTP文件传输错误-连接到未知服务器并添加其主机键。

SFTP文件传输错误-连接到未知服务器并添加其主机键。
EN

Stack Overflow用户
提问于 2021-03-23 06:16:40
回答 1查看 1.4K关注 0票数 1

我创建了这个批处理来使用SSH密钥传输文件,我检查了两个服务器上的公钥和私钥映射,并且它运行良好。

使用SFTP命令的Windows批处理代码如下:

代码语言:javascript
运行
复制
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作业(使用不同的用户)执行批处理时,下面的错误如下所示:

代码语言:javascript
运行
复制
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自动验证主机。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-23 07:12:57

若要在WinSCP脚本中验证主机密钥,请添加命令

代码语言:javascript
运行
复制
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或其他自动化服务运行时会失败或挂起。我做错了什么?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66758132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档