问题描述
我第一次尝试从 WinSCP 命令行连接到 Unix 服务器.
I am trying to connect to Unix server from WinSCP commandline for the first time.
它以以下错误关闭:
在缓存中找不到服务器的主机密钥.您无法保证服务器是您认为的计算机.
服务器的 rsa2 密钥指纹为:ssh-rsa 1024 42:9e:c7:f4:7f:8b:50:10:6a:06:04:b1:d4:f2:04:6d如果您信任此主机,请按是.在不向 cac 添加主机密钥的情况下进行连接他,按否要放弃连接按取消.
The server's rsa2 key fingerprint is: ssh-rsa 1024 42:9e:c7:f4:7f:8b:50:10:6a:06:04:b1:d4:f2:04:6d If you trust this host, press Yes. To connect without adding host key to the cac he, press No. To abandon the connection press Cancel.
在 WinSCP 命令行中,它不要求任何输入(是或否).它以身份验证失败结束.如果我通过 WinSCP 工具连接,我会得到同样的错误.但是,我将能够按 YES.
In the WinSCP commandline, it does not ask for any input (Yes or No). It closes with Authentication failed. If I connect through the WinSCP tool, I'll get the same error. However, I'll be able to press YES.
我也知道如果我在命令行中添加 -hostkey
开关,我将能够连接.但是,我不想在批处理脚本中传递主机密钥,因为我将连接到各种服务器.因此,我的要求是在出现此错误时从命令行传递YES"输入.有人可以帮忙吗?
I also know that If I add -hostkey
switch in the command line, I'll be able to connect. But, I don't want pass hostkey in my batch script as I will be connecting to various servers. So, my requirement is to pass "YES" input from the commandline in case of this error. Can someone help?
推荐答案
主机密钥指纹验证是保护 SSH 连接的关键步骤.即使您在脚本中使用了一组会话,这也不能成为您的借口.指纹应该是每个会话的一组信息的一部分(除了主机名、用户名和密码).
A host key fingerprint verification is a crucial step in securing your SSH connection. Even if you are using a set of sessions with your script, it does not excuse you. The fingerprint should be part of a set of information you have for each of the sessions (in addition to a hostname, an username and a password).
跳过指纹验证意味着您将失去任何安全性,并且不再使用 SSH/SFTP.
Skipping the fingerprint verification means that you lose any security and there's no point using an SSH/SFTP anymore.
无论如何,如果您不关心安全性,您可以使用 -hostkey=*
开关 无条件接受任何主机密钥.
Anyway, if you do not care about a security, you can use the -hostkey=*
switch to unconditionally accept any host key.
进一步参考:
这篇关于WinSCP 命令行:在缓存错误中找不到主机密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!