sshd

package
v0.0.0-...-9aee857 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

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

View Source
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"
)
View Source
const PrereceiveHookTpl = `` /* 326-byte string literal not displayed */

PrereceiveHookTpl is a pre-receive hook.

Variables

This section is empty.

Functions

func AuthKey

func AuthKey(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func Configure(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func Fingerprint(key ssh.PublicKey) string

Fingerprint generates a colon-separated fingerprint string from a public key.

func FingerprintKey

func FingerprintKey(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func ParseAuthorizedKeys(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func ParseHostKeys(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func Ping(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

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

func Serve(reg *cookoo.Registry, router *cookoo.Router, c cookoo.Context) cookoo.Interrupt

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.

func Start

func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Start starts an instance of /usr/sbin/sshd.

Types

type EnvVar

type EnvVar struct {
	Name  string
	Value string
}

EnvVar is an SSH env request

type ExecCmd

type ExecCmd struct {
	Value string
}

ExecCmd is an SSH exec request

type GenericMessage

type GenericMessage struct {
	Value string
}

GenericMessage describes a simple string message, which is common in SSH.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL