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 ¶
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) ClearAuthorizedKeys ¶
func (s *SSHServer) ClearAuthorizedKeys()
func (*SSHServer) RegisterCommand ¶
RegisterCommand adds a command that can be run by a user, by default only `help` is available