Documentation ¶
Index ¶
- func NewSession(commands *radix.Tree, conn *ssh.ServerConn, chans <-chan ssh.NewChannel, ...) *session
- type Command
- type CommandCallback
- type CommandFlags
- type SSHServer
- func (s *SSHServer) AddAuthorizedKey(user, pubKey string) error
- func (s *SSHServer) AddTrustedCA(pubKey string) error
- func (s *SSHServer) ClearAuthorizedKeys()
- func (s *SSHServer) ClearTrustedCAs()
- func (s *SSHServer) RegisterCommand(c *Command)
- func (s *SSHServer) Run(addr string) error
- func (s *SSHServer) SetHostKey(hostPrivateKey []byte) error
- func (s *SSHServer) Stop()
- type StringWriter
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 ¶
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 ¶
NewSSHServer creates a new ssh server rigged with default commands and prepares to listen
func (*SSHServer) AddAuthorizedKey ¶
AddAuthorizedKey adds an ssh public key for a user
func (*SSHServer) AddTrustedCA ¶
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 ¶
RegisterCommand adds a command that can be run by a user, by default only `help` is available