2011-02-02 20 views
2

我试图从一个网页启动另一台服务器上的perl脚本,我遇到了plink的问题:它似乎没有在从IUSR_用户运行时记住主机密钥。plink的主机密钥没有缓存在注册表中,当从IIS上运行Perl/Windows

我设法减少的问题是:

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运行时不能存储主机密钥。

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

回答

2

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

一些解决方法可能是:

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

你知道我该怎么做#1吗?在Unix上,我会做“sudo -u用户plink ...”,但我不知道在Windows上如何做到这一点... – 2011-02-02 18:57:25

+0

转到开始>>所有程序>>附件,然后右键单击“命令提示符”。选择“以管理员身份运行”或“以...身份运行” – mob 2011-02-02 20:16:20

0

我在tcl脚本中产生plink.exe(以及Expect命令),所以我无法使用pipe |因为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 
相关问题