class SSH2::KnownHosts

Overview

Manages a session's collection of known hosts, mirroring an OpenSSH known_hosts file: add and check host keys, and read/write the file.

Included Modules

Defined in:

known_hosts.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(session : Session) #

[View source]

Instance Method Detail

def add(host, salt, key, comment, typemask : LibSSH2::TypeMask) #

Add host with its key and typemask to the collection. salt is used for hashed hostnames (empty for a plain name). Returns the stored entry.


[View source]
def check(host, port, key, typemask : LibSSH2::TypeMask) #

Check host/port and key against the collection. Returns a LibSSH2::KnownHostCheck (MATCH, MISMATCH, NOTFOUND or FAILURE).


[View source]
def delete_if(&) #

Delete every known host for which the block returns a truthy value.


[View source]
def each(&) #

Yield each known host as a Host.


[View source]
def finalize #

[View source]
def read_file(filename) #

Populate the collection from an OpenSSH known_hosts file at filename.


[View source]
def read_line(line) #

Add a single host from one OpenSSH known_hosts line.


[View source]
def to_unsafe : Pointer(Void) #

[View source]
def write_file(filename) #

Write the collection to an OpenSSH known_hosts file at filename.


[View source]