Table of Contents

Method ForHost

Namespace
SshSharp.Config
Assembly
SshSharp.dll

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

host string

The host name or address.

port int

The port.

key SshPublicKey

The host's key. Its own comment is not used.

hash bool

Whether to store the host hashed.

comment string

An optional comment.

marker KnownHostsMarker

An optional marker.

Returns

KnownHostsEntry

Exceptions

ArgumentException

host contains white space or control characters, or comment contains control characters other than a tab.