Method AppendAsync
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
pathstringhoststringportintkeyTypestringpublicKeyReadOnlyMemory<byte>hashboolcancellationTokenCancellationToken
Returns
- Task<KnownHostsEntry>
The entry that was written.
AppendAsync(string, string, int, string, ReadOnlyMemory<byte>, bool, string?, KnownHostsMarker, CancellationToken)
Appends one entry to a file without rewriting it, as AppendAsync(string, string, int, string, ReadOnlyMemory<byte>, bool, CancellationToken) does, with a comment and a marker, as Add(string, int, string, ReadOnlySpan<byte>, bool, string?, KnownHostsMarker) takes them.
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
pathstringThe known_hosts file.
hoststringThe host name or address.
portintThe port.
keyTypestringThe key type, for example
ssh-ed25519.publicKeyReadOnlyMemory<byte>The public key blob.
hashboolWhether to store the host hashed (
HashKnownHosts).commentstringA comment for the line, or null.
markerKnownHostsMarkerA marker (
@cert-authority,@revoked), or none.cancellationTokenCancellationTokenCancels the write.
Returns
- Task<KnownHostsEntry>
The entry that was written.