Documentation
¶
Overview ¶
Package hosts describes saved SSH hosts and connects to them: password, private key or the panel's own key authentication, and host keys pinned on first use.
Index ¶
Constants ¶
const ( AuthPassword = "password" AuthKey = "key" // a private key stored with the host AuthPanel = "panel" // the panel's own key (see Keys) )
Authentication methods.
Variables ¶
var ErrInvalid = errors.New("invalid host")
ErrInvalid marks a host that fails validation.
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
*ssh.Client
// HostKey is the server's key in authorized_keys format; the caller
// pins it when the host had none.
HostKey string
}
Conn is an authenticated connection.
type Host ¶
type Host struct {
ID int64 `json:"id"`
Name string `json:"name"`
Address string `json:"address"` // host name or IP
Port int `json:"port"`
User string `json:"user"`
Auth string `json:"auth"`
Password string `json:"-"`
PrivateKey string `json:"-"` // PEM
Passphrase string `json:"-"` // of PrivateKey, if encrypted
// HostKey is the server's key pinned on first connection, in
// authorized_keys format; empty until then.
HostKey string `json:"-"`
Description string `json:"description"`
LastConnectedAt time.Time `json:"last_connected_at,omitzero"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Host is a saved SSH host. Secrets never leave the server: JSON carries only whether they are set.
type HostKeyError ¶
type HostKeyError struct {
Pinned, Offered string // SHA256 fingerprints
}
HostKeyError reports a server whose key differs from the pinned one: either the server was reinstalled or someone is in between. The operator must forget the pinned key to connect again.
func (*HostKeyError) Error ¶
func (e *HostKeyError) Error() string