Documentation ¶
Overview ¶
Package sshd implements an SSH server.
See https://tools.ietf.org/html/rfc4254
This was copied over (and effectively forked from) cookoo-ssh. Mainly this differs from the cookoo-ssh version in that this does not act like a stand-alone SSH server.
Index ¶
- Constants
- func AuthKey(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Configure(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Fingerprint(key ssh.PublicKey) string
- func FingerprintKey(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ParseAuthorizedKeys(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ParseHostKeys(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Ping(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Serve(reg *cookoo.Registry, router *cookoo.Router, c cookoo.Context) cookoo.Interrupt
- func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- type EnvVar
- type ExecCmd
- type GenericMessage
Constants ¶
const ( // HostKeys is the context key for Host Keys list. HostKeys string = "ssh.HostKeys" // Address is the context key for SSH address. Address string = "ssh.Address" // ServerConfig is the context key for ServerConfig object. ServerConfig string = "ssh.ServerConfig" )
Variables ¶
This section is empty.
Functions ¶
func AuthKey ¶
AuthKey authenticates based on a public key.
Params:
- metadata (ssh.ConnMetadata)
- key (ssh.PublicKey)
- authorizedKeys ([]string): List of lines from an authorized keys file.
Returns:
*ssh.Permissions
func Configure ¶
Configure creates a new SSH configuration object.
Config sets a PublicKeyCallback handler that forwards public key auth requests to the route named "pubkeyAuth".
This assumes certain details about our environment, like the location of the host keys. It also provides only key-based authentication. ConfigureServerSshConfig
Returns:
An *ssh.ServerConfig
func Fingerprint ¶
Fingerprint generates a colon-separated fingerprint string from a public key.
func FingerprintKey ¶
FingerprintKey fingerprints a key and returns the colon-formatted version
Params:
- key (ssh.PublicKey): The key to fingerprint.
Returns:
- A string representation of the key fingerprint.
func ParseAuthorizedKeys ¶
ParseAuthorizedKeys reads and process an authorized_keys file.
The file is merely parsed into lines, which are then returned in an array.
Params:
- path (string): The path to the authorized_keys file.
Returns:
[]string of keys.
func ParseHostKeys ¶
ParseHostKeys parses the host key files.
By default it looks in /etc/ssh for host keys of the patterh ssh_host_{{TYPE}}_key.
Params:
- keytypes ([]string): Key types to parse. Defaults to []string{rsa, dsa, ecdsa}
- enableV1 (bool): Allow V1 keys. By default this is disabled.
- path (string): Override the lookup pattern. If %s, it will be replaced with the keytype.
Returns:
[]ssh.Signer
func Ping ¶
Ping handles a simple test SSH exec.
Returns the string PONG and exit status 0.
Params:
- channel (ssh.Channel): The channel to respond on.
- request (*ssh.Request): The request.
func Serve ¶
Serve starts a native SSH server.
The general design of the server is that it acts as a main server for a Cookoo app. It assumes that certain things have been configured for it, like an ssh.ServerConfig. Once it runs, it will block until the main process terminates. If you want to stop it prior to that, you can grab the closer ("sshd.Closer") out of the context and send it a signal.
Currently, the service is not generic. It only runs git hooks.
This expects the following Context variables.
- ssh.Hostkeys ([]ssh.Signer): Host key, as an unparsed byte slice.
- ssh.Address (string): Address/port
- ssh.ServerConfig (*ssh.ServerConfig): The server config to use.
This puts the following variables into the context:
- ssh.Closer (chan interface{}): Send a message to this to shutdown the server.
Types ¶
type GenericMessage ¶
type GenericMessage struct {
Value string
}
GenericMessage describes a simple string message, which is common in SSH.