Documentation ¶
Overview ¶
Package knownhosts implements a parser for the OpenSSH known_hosts host key database.
Index ¶
- func HashHostname(hostname string) string
- func Line(addresses []string, key ssh.PublicKey) string
- func New(files ...string) (ssh.HostKeyCallback, error)
- func Normalize(address string) string
- func OrderHostKeyAlgs(address string, remote net.Addr, files ...string) []string
- type KeyError
- type KnownKey
- type RevokedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashHostname ¶
HashHostname hashes the given hostname. The hostname is not normalized before hashing.
func New ¶
func New(files ...string) (ssh.HostKeyCallback, error)
New creates a host key callback from the given OpenSSH host key files. The returned callback is for use in ssh.ClientConfig.HostKeyCallback. Hashed hostnames are not supported.
Types ¶
type KeyError ¶
type KeyError struct { // Want holds the accepted host keys. For each key algorithm, // there can be one hostkey. If Want is empty, the host is // unknown. If Want is non-empty, there was a mismatch, which // can signify a MITM attack. Want []KnownKey }
KeyError is returned if we did not find the key in the host key database, or there was a mismatch. Typically, in batch applications, this should be interpreted as failure. Interactive applications can offer an interactive prompt to the user.
type RevokedError ¶
type RevokedError struct {
Revoked KnownKey
}
RevokedError is returned if we found a key that was revoked.
func (*RevokedError) Error ¶
func (r *RevokedError) Error() string