使用plink自动将服务器主机密钥存储在高速caching中

我一直在尝试使用plink发出命令来从我的外部服务器检索信息。 请注意,这些plink命令是从不需要用户input的二进制文件运行的。 有没有一个标志,将允许我重写这个错误消息,并继续与程序输出?

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 **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:** 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) 

谢谢!

尝试将脚本添加到:

 echo y | plink -ssh root@REMOTE_IP_HERE "exit" 

这将通过stdiny字符到plink当你获得存储键caching? (y / n)提示符,允许所有进一步的plink命令通过,而不需要用户input。 exit命令将在SSH会话build立后closures,允许运行下面的plink命令。

下面是一个示例脚本,它将外部服务器的Unix时间写入本地文件:

 echo y | plink -ssh root@REMOTE_IP_HERE "exit" plink -ssh root@REMOTE_IP_HERE "date -t" > remote_time.tmp 

pipe道参考 : http : //tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html

也许,这将有助于:

 plink -auto_store_sshkey -batch 192.211.158.256 -l user -pw password command