Is there any way to automatically accept SSH host keys—even when keys are changed—in PuTTY?
We use some software that will SSH to a bunch of machines and do something. The problem is in our test lab, the virtual machine’s are re-new (destroy and re-created) very often, so the software will treat the virtual machine as new, which it is, and will fail because the authenticity of the host cannot be established. I was told to manually PuTTY in and accept the host key, and after the software will be happy.
Doing this with a few hundreds virtual machines is not fun.
So, I want to know is there any a command tool that I can automate to accept the host key for PuTTY? We are in a closed lab, so I am not too worried about security.
I know there are some solutions for Linux environment, but this one is Windows.
@Paul above suggested to use pscp. It works great, is super simple, and totally scriptable:
C:\> echo y | pscp.exe -l user -pw password -ls 192.168.0.1:/
On their official site, the developers made clear that such a feature won't be available in PuTTY (emphasis by me):
An option to automatically accept all SSH host keys. For some reason lots of people seem to think this would be a really useful feature. I'm sure it would be very convenient, but at the expense of security! The whole point of host keys is that they're the only guarantee you have that your connection hasn't been hijacked by an active attacker between you and the server, and that your data isn't being decrypted by the attacker and re-encrypted. If you want to schedule an automated batch job to use PSCP or Plink, and the interactive host key prompt is making this difficult, add the correct host key to the registry ahead of time. (Update, 2014-09-09: or if the Registry isn't available, you can use the new -hostkey option to specify the right key or fingerprint on the command line.) That way you still get the convenience, but without losing the security. We will not accept a command line option to turn off host key checking, no matter how many people have already done the work and send us polished production-quality patches.
If you have host keys available in the common `known_hosts' format, we have a script to convert them to a Windows .REG file which can be installed ahead of time by double-clicking.
Source: http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/accept-host-keys.html
So unfortunately, PuTTY cannot achieve this without user interaction.