Table of Contents

Method AppendAsync

Namespace
SshSharp.Config
Assembly
SshSharp.dll

AppendAsync(string, string, int, string, ReadOnlyMemory<byte>, bool, CancellationToken)

Appends one entry to a file without rewriting it (creating the file and directory if needed), the way ssh records a new host key. Other processes appending at the same time do not lose their lines, unlike a load-modify-save.

public static Task<KnownHostsEntry> AppendAsync(string path, string host, int port, string keyType, ReadOnlyMemory<byte> publicKey, bool hash = false, CancellationToken cancellationToken = default)

Parameters

path string
host string
port int
keyType string
publicKey ReadOnlyMemory<byte>
hash bool
cancellationToken CancellationToken

Returns

Task<KnownHostsEntry>

The entry that was written.

AppendAsync(string, string, int, string, ReadOnlyMemory<byte>, bool, string?, KnownHostsMarker, CancellationToken)

public static Task<KnownHostsEntry> AppendAsync(string path, string host, int port, string keyType, ReadOnlyMemory<byte> publicKey, bool hash, string? comment, KnownHostsMarker marker = KnownHostsMarker.None, CancellationToken cancellationToken = default)

Parameters

path string

The known_hosts file.

host string

The host name or address.

port int

The port.

keyType string

The key type, for example ssh-ed25519.

publicKey ReadOnlyMemory<byte>

The public key blob.

hash bool

Whether to store the host hashed (HashKnownHosts).

comment string

A comment for the line, or null.

marker KnownHostsMarker

A marker (@cert-authority, @revoked), or none.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<KnownHostsEntry>

The entry that was written.