ssh

package
v0.0.0-...-8876515 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package ssh contains the ssh control interface

Index

Constants

This section is empty.

Variables

View Source
var HostKeyFile string

HostKeyFile is the path to the host key to use for the ssh control interface

Functions

func ReadUsersFile

func ReadUsersFile(filename string) (map[string]UserAuth, error)

ReadUsersFile reads a json file containing all users and passwords allowed to access the ssh control interface It returns a dictionary user->password

func RegisterCommand

func RegisterCommand(c Command)

RegisterCommand registers a command to allow its use from ssh control interface

func StartSSH

func StartSSH(address string, users map[string]UserAuth)

StartSSH starts the ssh control interface on listening on address and accepting all users with the respective passwords in the users dict (user->password)

Types

type Command

type Command struct {
	Name  string // Name is the name of the command, which is used to access it from the terminal
	Usage string // Usage contains usage information for the command
	Info  string // Info contains information about what the command does
	// Exec runs the command. It is passed the arguments as a string slice.
	// If it returns false, a usage message is printed, otherwise the returned string is printed
	ExecFunc func(args []string) (string, bool)
	// OptionsFunc (optional) is used for auto completion. It is passed a prefix and the number of the argument and should
	// return all possible completion options
	OptionsFunc func(prefix string, arg int) []string
}

Command describes a ssh command

func (Command) Exec

func (command Command) Exec(args []string) (string, bool)

Exec executes ExecFunc

func (Command) GetName

func (command Command) GetName() string

GetName returns the printable name of the command

func (Command) Options

func (command Command) Options(prefix string, arg int) []string

Options executes OptionsFunc (if provided) or returns []string{}

type UserAuth

type UserAuth struct {
	Password string `json:"password"`
	PubKey   []byte `json:"pubKey"`
}

UserAuth contains the data to authenticate a user connection to the ssh control interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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