Documentation ¶
Overview ¶
Package ssh implements a parser for the OpenSSH known_hosts host key database, and provides utility functions for writing OpenSSH compliant known_hosts files.
Index ¶
- func HashHostname(hostname string) string
- func Line(addresses []string, key ssh.PublicKey) string
- func New(files ...string) (ssh.HostKeyCallback, *hostKeyDB, error)
- func Normalize(address string) string
- func RefreshKnownHosts() error
- type Conn
- type Connection
- type KeyError
- type KnownKey
- type RevokedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashHostname ¶ added in v0.0.2
HashHostname hashes the given hostname. The hostname is not normalized before hashing.
func New ¶ added in v0.0.2
func New(files ...string) (ssh.HostKeyCallback, *hostKeyDB, error)
New creates a host key hostCallback from the given OpenSSH host key files. The returned hostCallback is for use in ssh.ClientConfig.HostKeyCallback. By preference, the key check operates on the hostname if available, i.e. if a server changes its IP address, the host key check will still succeed, even though a record of the new IP address is not available.
func RefreshKnownHosts ¶ added in v0.1.4
func RefreshKnownHosts() error
Types ¶
type Connection ¶
func NewConnection ¶
func NewConnection(addr, user string) (*Connection, error)
func (*Connection) Addr ¶ added in v0.1.6
func (c *Connection) Addr() string
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) IsValid ¶
func (c *Connection) IsValid() bool
func (*Connection) MultipleRun ¶
func (c *Connection) MultipleRun(commands ...string) (string, error)
type KeyError ¶ added in v0.0.2
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 ¶ added in v0.0.2
type RevokedError struct {
Revoked KnownKey
}
RevokedError is returned if we found a key that was revoked.
func (*RevokedError) Error ¶ added in v0.0.2
func (r *RevokedError) Error() string