ssh with putty from session 0 gives 'servers host key does not match ...' alert

1.4k views Asked by At

I have some test code running from TeamCity. Part of my test code requires ssh with putty. This code works fine in in a command prompt (session 1) but when I run it from TeamCity (which is a process and therefore runs in session 0) I get the following alert in my test log

The servers host key does not match the one PuTTY has cached in the registry [snip] 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)

Since this is in session 0 I can't interact and hit 'y'. I can't work out why the key stored in the registry when I hit 'y' when running this the first time from session 1 doesn't stop the alert appearing in session 0.

Can anyone help me? Thanks.

1

There are 1 answers

0
EnzoR On

Very likely there is no solution with PuTTY.

In OpenSSH you have a set of options to completely avoid the host key verification, with the drawback of lowering the security levels.

On Unix derivatives that would be:

-o  StrictHostKeyChecking=no -o  UserKnownHostsFile=/dev/null

I think in Windows the second option would read "-o UserKnownHostsFile=NULL".

One possible "workaround" would be to manually start putty on the very first connection in order to get the host key in the stored cache. Subsequent calls would not require the interaction unless the host key changes (usually due to either a system re-installation or just the SSH server reinstallation).