sshd

package
v2.7.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package sshd implements an SSH server.

See https://tools.ietf.org/html/rfc4254

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"
)

Variables

This section is empty.

Functions

func AuthKey

func AuthKey(key ssh.PublicKey, cnf *Config) (*ssh.Permissions, error)

AuthKey authenticates based on a public key.

func Configure

func Configure(cnf *Config) (*ssh.ServerConfig, error)

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 Ping

func Ping(channel ssh.Channel, req *ssh.Request) error

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(
	cfg *ssh.ServerConfig,
	serverCircuit *Circuit,
	gitHomeDir string,
	concurrentPushLock RepositoryLock,
	addr, receivetype string) error

Serve starts a native SSH server.

Types

type Circuit

type Circuit struct {
	// contains filtered or unexported fields
}

Circuit is a concurrency-safe data structure that can take one of two states at any point in time:

- OpenState - non functional - ClosedState - functional

The circuit is intended as a point-in-time indicator of functionality. It has no backoff mechanism, jitter or ramp-up/ramp-down functionality.

func NewCircuit

func NewCircuit() *Circuit

NewCircuit creates a new circuit, in the open (non-functional) state.

func (*Circuit) Close

func (c *Circuit) Close() bool

Close closes the circuit if it wasn't already closed. Returns true if it had to be closed, false if it was already closed.

func (*Circuit) Open

func (c *Circuit) Open() bool

Open opens the circuit if it wasn't already closed. Returns true if it had to be opened, false if it was already open.

func (*Circuit) State

func (c *Circuit) State() CircuitState

State returns the current state of the circuit. Note that concurrent modifications may be happening, so the state may be different than what's returned.

type CircuitState

type CircuitState uint32

CircuitState represents the state of a Circuit.

const (
	// OpenState indicates that the circuit is in the open state, and thus non-functional.
	OpenState CircuitState = 0
	// ClosedState indicates that the circuit is in the closed state, and thus functional.
	ClosedState CircuitState = 1
)

func (CircuitState) String

func (c CircuitState) String() string

String is the fmt.Stringer interface implementation.

type Config

type Config struct {
	ControllerHost               string `envconfig:"DEIS_CONTROLLER_SERVICE_HOST" required:"true"`
	ControllerPort               string `envconfig:"DEIS_CONTROLLER_SERVICE_PORT" required:"true"`
	SSHHostIP                    string `envconfig:"SSH_HOST_IP" default:"0.0.0.0" required:"true"`
	SSHHostPort                  int    `envconfig:"SSH_HOST_PORT" default:"2223" required:"true"`
	HealthSrvPort                int    `envconfig:"HEALTH_SERVER_PORT" default:"8092"`
	HealthSrvTestStorageRegion   string `envconfig:"STORAGE_REGION" default:"us-east-1"`
	CleanerPollSleepDurationSec  int    `envconfig:"CLEANER_POLL_SLEEP_DURATION_SEC" default:"5"`
	StorageType                  string `envconfig:"BUILDER_STORAGE" default:"minio"`
	SlugBuilderImagePullPolicy   string `envconfig:"SLUG_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
	DockerBuilderImagePullPolicy string `envconfig:"DOCKER_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
	LockTimeout                  int    `envconfig:"GIT_LOCK_TIMEOUT" default:"10"`
}

Config represents the required SSH server configuration.

func (Config) CleanerPollSleepDuration

func (c Config) CleanerPollSleepDuration() time.Duration

CleanerPollSleepDuration returns c.CleanerPollSleepDurationSec as a time.Duration.

func (Config) GitLockTimeout

func (c Config) GitLockTimeout() time.Duration

GitLockTimeout return LockTimeout in minutes

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.

type RepositoryLock

type RepositoryLock interface {
	// Lock acquires a lock for a repository.
	Lock(repoName string) error
	// Unlock releases the lock for a repository or returns an error if the specified
	// name doesn't exist.
	Unlock(repoName string) error
	// Timeout returns the time duration for which it has to hold the lock
	Timeout() time.Duration
}

RepositoryLock interface that allows the creation of a lock associated with a repository name to avoid simultaneous git operations.

func NewInMemoryRepositoryLock

func NewInMemoryRepositoryLock(timeout time.Duration) RepositoryLock

NewInMemoryRepositoryLock returns a new instance of a RepositoryLock.

Jump to

Keyboard shortcuts

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