2014-08-31 261 views
3

我试图从WinSCP命令行第一次连接到Unix服务器。WinSCP命令行:在缓存中找不到主机密钥错误

它关闭与以下错误:

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 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。

我也知道如果我在命令行中添加-hostkey开关,我将能够连接。但是,我不想在我的批处理脚本中传递hostkey,因为我将连接到各种服务器。所以,我的要求是在命令行中输入“YES”输入以防出现此错误。有人可以帮忙吗?

回答

1

主机密钥指纹验证是保护SSH连接的关键步骤。即使您正在使用与您的脚本进行的一组会话,也不能原谅您。指纹应该是您为每个会话(除了主机名,用户名和密码以外)提供的一组信息的一部分。

跳过指纹验证意味着您失去了任何安全性,并且没有必要再使用SSH/SFTP。

无论如何,如果您不关心安全性,您可以使用-hostkey=* switch无条件接受任何主机密钥。

更多参考:

+0

喜@马丁,这不是为我工作。调用C:\ Progra〜2 \ WinSCP \ WinSCP.exe/console -timeout =“120”/ command“option batch continue”“option confirm off”“open sftp://%userin%:%pasw%@ host --hostkey =“*”“”get /home/*.*“ – 2014-09-05 18:54:29

+0

您的命令与Markdown语法冲突,所以我无法从字面上看到它。但我认为原来是''open sftp://%userin%:%pasw%@ host -hostkey =“*”“'。这是错误的,或者使用''open open sftp://%userin%:%pasw%@ host -hostkey =“”*“”“'或避免引用'*':'”open sftp://%userin% %pasw%@ host -hostkey = *“'请参阅[命令行语法](http://winscp.net/eng/docs/commandline#syntax)。 – 2014-09-05 19:00:43

+0

另外'-timeout =“120”'指定为命令行参数不适用于使用脚本命令打开的会话。您必须将其与'open'命令结合使用:'“open sftp://%userin%:%pasw%@ host -hostkey = * -timeout = 120”' – 2014-09-05 19:03:22