Method ForHost
ForHost(string, int, SshPublicKey, bool, string?, KnownHostsMarker)
Creates the entry ssh writes for one host's key: the host as FormatHost(string, int) stores it ([host]:port for a
port other than 22), or hashed (HashHost(string, int, ReadOnlySpan<byte>), with a random salt) as with HashKnownHosts yes.
Add(string, int, SshPublicKey, bool, string?, KnownHostsMarker) and
AppendAsync(string, string, int, SshPublicKey, bool, string?, KnownHostsMarker, CancellationToken)
write the same.
public static KnownHostsEntry ForHost(string host, int port, SshPublicKey key, bool hash = false, string? comment = null, KnownHostsMarker marker = KnownHostsMarker.None)
Parameters
hoststringThe host name or address.
portintThe port.
keySshPublicKeyThe host's key. Its own comment is not used.
hashboolWhether to store the host hashed.
commentstringAn optional comment.
markerKnownHostsMarkerAn optional marker.
Returns
Exceptions
- ArgumentException
hostcontains white space or control characters, orcommentcontains control characters other than a tab.