在IIS / Windows上从perl运行时,plink的主机密钥不会缓存在注册表中

时间:2011-02-02 16:40:43

标签: windows perl iis plink

我正在尝试从网页上的另一台服务器上启动perl脚本,我遇到了plink的问题:从IUSR_用户运行时,它似乎不记得主机密钥。

我设法减少了这个问题:

print "Content-Type:text/plain\n\n";
open(PLINK, "| \"C:\\Program Files\\PuTTY\\plink.exe\" -pw sanitized Administrator\@serveurftp.a.b.c whoami") or die "Can't fork: $!";
sleep(1);
print PLINK "y\n";
close(PLINK);

从网页调用此脚本时,我总是这样:

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 cb:eb:dc:1b:9e:1c:6b:fa:63:fb:2e:ba:2c:61:26:c4
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) serveurftp\administrator

我应该只是第一次得到这个,之后只有“serveurftp \ administrator”,但看起来plink在从IIS运行时无法存储主机密钥。

你们对如何解决这个问题有什么想法吗?

3 个答案:

答案 0 :(得分:2)

在这种情况下,应用程序通常会尝试从控制台(或在Unix中说,tty)读取y / n响应,而不一定是从标准输入读取,因此程序可能没有注册“y”管道到它的响应。

一些解决方法可能是:

  1. 从命令行运行命令作为IIS用户。也许这会使主持人继续接听来自网络服务器的电话。
  2. 自己从命令行运行命令。找到用户的缓存文件,并将该文件中的密钥复制到管理员的缓存文件中。
  3. 如果您的网络服务器程序在您的计算机上有一个控制台窗口,请尝试从浏览器访问此脚本,然后在脚本到达提示您进行此响应的位置时在该控制台窗口中键入“y”(这可能赢了因为该程序可能已经在子进程中运行,但是它可能值得一试)

答案 1 :(得分:0)

此处提供的解决方案(感谢Dean Grant):

Accept server host key when automating SSH session using PuTTY Plink

答案 2 :(得分:0)

我在tcl脚本中生成plink.exe(以及Expect命令),所以我无法使用管道因为tcl不承认它。我通过产生plink,推出一个“y”,退出,然后再次产生plink来实现同样的目的。

#Push a "y" to overcome ssh host key challenge
spawn plink -ssh 192.168.1.1 -l username -pw password
send -s "y\r"
send -s "exit\r"

#ssh into host
spawn plink -ssh 192.168.1.1 -l username -pw password
相关问题