Table of Contents

Class KnownHostsEntry

Namespace
SshSharp.Config
Assembly
SshSharp.dll

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.

KnownHostsEntry(string, string, ReadOnlyMemory<byte>, KnownHostsMarker, string?)

Creates an entry.

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.

Marker

The marker (@cert-authority, @revoked) or None.

PublicKey

The public key blob.

Methods

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.

FormatHost(string, int)

Formats a host and port the way known_hosts stores them: host, or [host]:port for 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_hosts line (no line terminator).