Hi
I know that Net::SSH2::KnownHosts is marked as experimental.
I make very good use of it and I have a suggestion for an enhancement to it.
My Perl application code acts as an SSH terminal and I can spawn many instances of it.
The way I deal with unknown SSH hosts is that I automatically add them to the known_hosts file the 1st time, and this is done with a call to:
$kh->add(...)
$kh->writefile($known_hosts_path)
But if multiple instances of my application code do it at the same time, the known_hosts file can get corrupted.
It would be nice if these methods could accept a filehandle as well as a filename.
$kh->readfile($file_or_filehandle)
$kh->writefile($file_or_filehandle)
Then one could use flock() on the filehandle before handing it over to the above methods. This would prevent simultaneous writes to the same file as well as reading the file while it is being modified.
I have a workaround in place, but thought I'd ask anyway.
Thanks for writing the module.
Best regards
Ludovico Stevens