Table of Contents

Constructor KnownHostsEntry

Namespace
SshSharp.Config
Assembly
SshSharp.dll

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

Creates an entry.

public KnownHostsEntry(string hostPatterns, string keyType, ReadOnlyMemory<byte> publicKey, KnownHostsMarker marker = KnownHostsMarker.None, string? comment = null)

Parameters

hostPatterns string

Comma-separated host patterns, or a single hashed host (|1|salt|hash).

keyType string

The key type, for example ssh-ed25519.

publicKey ReadOnlyMemory<byte>

The public key blob (the decoded base64 field).

marker KnownHostsMarker

The optional marker.

comment string

The optional trailing comment.

Exceptions

ArgumentException

hostPatterns or keyType is empty or contains white space or control characters, hostPatterns starts with @ or # (the line would be read as a marker line or a comment), or comment contains control characters other than a tab. Any of them would let ToLine() write extra fields or extra lines (a @cert-authority line, say) into known_hosts.

KnownHostsEntry(string, SshPublicKey, KnownHostsMarker, string?)

Creates an entry for key, with its type and blob. The key's own Comment is not used.

public KnownHostsEntry(string hostPatterns, SshPublicKey key, KnownHostsMarker marker = KnownHostsMarker.None, string? comment = null)

Parameters

hostPatterns string

Comma-separated host patterns, or a single hashed host (HashHost(string, int, ReadOnlySpan<byte>)).

key SshPublicKey

The key.

marker KnownHostsMarker

The optional marker.

comment string

The optional trailing comment.