Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { sync.Mutex // Deadline is the maximum time the listener will block // between connections. As a consequence, this duration // also sets the max length of time the SSH server will // be unresponsive before shutting down. Deadline time.Duration // Handlers is a map of SSHHandlers which process incoming connections. The map // consists of channel names as keys and SSHHandlers as the values. If a // client connects and creates a channel with a defined SSHHandler, the handler // will process all requests on that channel. If a channel is accepted without a // defined handler, the channel is closed as well as the connection. Handlers map[string]SSHHandler // Logger logs errors and debug output for the SSH server. Logger log.Logger // Bind specifies the Bind address the SSH server will listen on. Bind string // PrivateKey is added to the SSH config as a host key. PrivateKey ssh.Signer // AuthLogCallback, if non-nil, is called to log all authentication // attempts. AuthLogCallback func(conn ssh.ConnMetadata, method string, err error) // PasswordCallback, if non-nil, is called when a user // attempts to authenticate using a password. PasswordCallback func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) // PublicKeyCallback, if non-nil, is called when a client attempts public // key authentication. It must return true if the given public key is // valid for the given user. For example, see CertChecker.Authenticate. PublicKeyCallback func(ssh.ConnMetadata, ssh.PublicKey) (*ssh.Permissions, error) // contains filtered or unexported fields }
Config is used to setup the SSHServer, including the server config and the SSHHandlers.
func (*Config) Handler ¶
func (c *Config) Handler(channel string) (handler SSHHandler, ok bool)
Handler is a helper method for determining if a channel handler has been defined.
func (*Config) SSHConfig ¶
func (c *Config) SSHConfig() *ssh.ServerConfig
SSHConfig returns an SSH server configuration. If the AuthLogCallback is nil at the time this method is called, the default function will be used.
type SSHHandler ¶
type SSHHandler interface { // Handle processes SSH connections. The requests chan can be disregarded if it is not needed. Handle(t tomb.Tomb, conn *ssh.ServerConn, channel ssh.Channel, requests <-chan *ssh.Request) error }
A SSHHandler is registered with an SSH server to process incoming connections on a particular channel.
type SSHServer ¶
SSHServer handles all the incoming connections as well as handler dispatch.
func NewSSHServer ¶
NewSSHServer creates a new server with the given config. The server will call `cfg.SSHConfig()` to setup the server. If an error occurs it will be returned. If the Bind address is empty or invalid an error will be returned. If there is an error starting the TCP server, the error will be returned.