Re: Using Public Keys on many remote PCs
As you have thrown away my effort in helping you by deleting my answer on Stack Overflow, I'm at least re-posting it here:
A host key is part of the information you need to know about about each server upfront, along with the hostname and credentials. You should get the information from the administrator of the server. See also Where do I get SSH host key fingerprint to authorize the server?
While you can automate the retrieval of the keys, it is not the best solution. If you want to do that anyway, you can make use of WinSCP .NET assembly
A host key is part of the information you need to know about about each server upfront, along with the hostname and credentials. You should get the information from the administrator of the server. See also Where do I get SSH host key fingerprint to authorize the server?
While you can automate the retrieval of the keys, it is not the best solution. If you want to do that anyway, you can make use of WinSCP .NET assembly
Session.ScanFingerprint
, e.g. from PowerShell script like:
Add-Type -Path "WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions
$session = New-Object WinSCP.Session
$hostnames = "example.com", "example.net", "example.org"
foreach ($hostname in $hostnames)
{
$sessionOptions.HostName = $hostname
$fp = $session.ScanFingerprint($sessionOptions, "SHA-256")
Write-Host "$hostname = $fp"
}