sshd

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSession

func NewSession(commands *radix.Tree, conn *ssh.ServerConn, chans <-chan ssh.NewChannel, l *logrus.Entry) *session

Types

type Command

type Command struct {
	Name             string
	ShortDescription string
	Help             string
	Flags            CommandFlags
	Callback         CommandCallback
}

type CommandCallback

type CommandCallback func(fs interface{}, a []string, w StringWriter) error

CommandCallback is the function called when your command should execute. fs will be a a pointer to the struct provided by Command.Flags callback, if there was one. -h and -help are reserved and handled automatically for you. a will be any unconsumed arguments, if no Command.Flags was available this will be all the flags passed in. w is the writer to use when sending messages back to the client. If an error is returned by the callback it is logged locally, the callback should handle messaging errors to the user where appropriate

type CommandFlags

type CommandFlags func() (*flag.FlagSet, interface{})

CommandFlags is a function called before help or command execution to parse command line flags It should return a flag.FlagSet instance and a pointer to the struct that will contain parsed flags

type SSHServer

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

func NewSSHServer

func NewSSHServer(l *logrus.Entry) (*SSHServer, error)

NewSSHServer creates a new ssh server rigged with default commands and prepares to listen

func (*SSHServer) AddAuthorizedKey

func (s *SSHServer) AddAuthorizedKey(user, pubKey string) error

AddAuthorizedKey adds an ssh public key for a user

func (*SSHServer) AddTrustedCA

func (s *SSHServer) AddTrustedCA(pubKey string) error

AddTrustedCA adds a trusted CA for user certificates

func (*SSHServer) ClearAuthorizedKeys

func (s *SSHServer) ClearAuthorizedKeys()

func (*SSHServer) ClearTrustedCAs

func (s *SSHServer) ClearTrustedCAs()

func (*SSHServer) RegisterCommand

func (s *SSHServer) RegisterCommand(c *Command)

RegisterCommand adds a command that can be run by a user, by default only `help` is available

func (*SSHServer) Run

func (s *SSHServer) Run(addr string) error

Run begins listening and accepting connections

func (*SSHServer) SetHostKey

func (s *SSHServer) SetHostKey(hostPrivateKey []byte) error

func (*SSHServer) Stop

func (s *SSHServer) Stop()

type StringWriter

type StringWriter interface {
	WriteLine(string) error
	Write(string) error
	WriteBytes([]byte) error
	GetWriter() io.Writer
}

Jump to

Keyboard shortcuts

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