当在IIS / Windows上从perl运行时,plink的主机密钥不会被caching在registry中

我试图从网页上启动另一台服务器上的perl脚本,而且我遇到了plink问题:从IUSR_用户运行时似乎没有记住主机密钥。

我设法减less这个问题:

print "Content-Type:text/plain\n\n"; open(PLINK, "| \"C:\\Program Files\\PuTTY\\plink.exe\" -pw sanitized Administrator\@serveurftp.abc 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 \pipe理员”之后,但它看起来像plink不能存储主机密钥时,从IIS运行。

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

在这种情况下,应用程序通常会尝试从控制台(或者Unix的tty,tty)读取y / n响应,而不一定是从标准输入读取响应,所以程序可能不会记录你的“y”响应管道到它。

一些解决方法可能是:

  1. 从命令行以IIS用户身份运行该命令。 也许这将坚持来自网络服务器的呼叫的主机。
  2. 像你一样从命令行运行命令。 找到用户的缓存文件,并将该文件中的密钥复制到管理员的缓存文件中。
  3. 如果您的Web服务器程序在您的机器上有一个控制台窗口,请尝试从浏览器访问此脚本,然后在脚本到达提示您进行响应的位置时,在该控制台窗口中键入“y”(这可能不起作用因为程序可能已经在一个子进程中运行了,但是可能值得一试)

这里提供的解决方案(感谢院长格兰特):

使用PuTTY Plink自动执行SSH会话时接受服务器主机密钥

我在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