Auto-storing server host key in cache with plink
kevin.Zhu 发布于:2022-5-19 12:44 分类:文摘 有 17 人浏览,获得评论 0 条
https://bootpanic.com/auto-storing-server-host-key-in-cache-with-plink/
Try prepending your script with:
echo y | plink -ssh root@REMOTE_IP_HERE "exit"
This will pipe the y
character through stdin
to plink
when you get the Store key in cache? (y/n) prompt, allowing all further plink
commands to pass through without the need of user input. The exit
command will close the SSH session after it has been established, allowing the following plink
commands to run.
Here’s an example script which writes the external server’s Unix time to a local file:
echo y | plink -ssh root@REMOTE_IP_HERE "exit"
plink -ssh root@REMOTE_IP_HERE "date -t" > remote_time.tmp