Class KnownHostsEntry
One parsed known_hosts line.
public sealed class KnownHostsEntry
- Inheritance
-
KnownHostsEntry
- Inherited Members
Constructors
- KnownHostsEntry(string, SshPublicKey, KnownHostsMarker, string?)
Creates an entry for
key, with its type and blob. The key's own Comment is not used.
Properties
- Comment
The trailing comment, if any.
- HostPatterns
The raw host field: comma-separated patterns, or a single hashed host.
- IsHashed
Whether the host field is hashed (
|1|salt|hash).
- KeyType
The key type, for example
ssh-ed25519.
- PublicKey
The public key blob.
Methods
- ForHost(string, int, SshPublicKey, bool, string?, KnownHostsMarker)
Creates the entry
sshwrites for one host's key: the host as FormatHost(string, int) stores it ([host]:portfor a port other than 22), or hashed (HashHost(string, int, ReadOnlySpan<byte>), with a random salt) as withHashKnownHosts yes. Add(string, int, SshPublicKey, bool, string?, KnownHostsMarker) and AppendAsync(string, string, int, SshPublicKey, bool, string?, KnownHostsMarker, CancellationToken) write the same.
- FormatHost(string, int)
Formats a host and port the way
known_hostsstores them:host, or[host]:portfor non-22 ports.
- GetPublicKey()
PublicKey as an SshPublicKey, with the entry's Comment.
- HashHost(string, int, ReadOnlySpan<byte>)
Creates a hashed host field (
|1|salt|hash) for a host and port.
- Matches(string, int)
Whether this entry applies to a host and port.
- ToLine()
Formats the entry as a
known_hostsline (no line terminator).