Documentation ¶
Index ¶
- Constants
- func StartSSHShell(ctx context.Context, createRoot func() *cobra.Command, config *Config)
- type Auth
- type Config
- type Handler
- type HandlerFactory
- type HostKeyResolver
- type SSHServer
- type Shell
- func (s *Shell) Add(b byte) error
- func (s *Shell) AddString(val string) error
- func (s *Shell) Bell() error
- func (s *Shell) GetReadWrite() io.ReadWriter
- func (s *Shell) InstanceName() string
- func (s *Shell) Output(line string) error
- func (s *Shell) OutputLine(line string) error
- func (s *Shell) Read(line string) (string, bool, error)
- func (s *Shell) Refresh() error
- func (s *Shell) SetPrompt(prompt string)
- type User
Constants ¶
View Source
const ( DefaultConfigHistorySize = 100 DefaultBind = ":22" )
View Source
const ( ETX = 0x3 // control-C EOT = 0x4 // control-D BEL = 0x7 // beep BS = 0x8 // Backspace TAB = 0x9 // TAB LF = 0xa // linefeed FF = 0xc // formfeed (go to top of next page) CR = 0xd // carriage return ESC = 0x1b // Escape CSI = '[' // CSI escape code following DEL = 0x7f // Delete CUU = 'A' // Cursor Up CUD = 'B' // Cursor Down CUF = 'C' // Cursor Forward CUB = 'B' // Cursor Back )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler interface { // HandleLine is called with the next line that was consumed by the SSH shell. Typically this is due the user typing // a command string. If an error is returned, then the error is reported back to the SSH client and the SSH session // is closed. HandleLine(ctx context.Context, line string) error // handle completion requests HandleCompletion(ctx context.Context, line string) (string, error) // HandleEOF is called when the user types Control-D. If an error is returned, then the error is reported back to the // SSH client and the SSH session is closed. HandleEOF() error }
type HandlerFactory ¶
type HostKeyResolver ¶
type HostKeyResolver struct {
// contains filtered or unexported fields
}
func NewHostKeyResolver ¶
func NewHostKeyResolver(config *Config) *HostKeyResolver
func (*HostKeyResolver) Resolve ¶
func (r *HostKeyResolver) Resolve() string
func (*HostKeyResolver) ResolveOption ¶
func (r *HostKeyResolver) ResolveOption() ssh.Option
type SSHServer ¶
type SSHServer struct { *Config HandlerFactory // contains filtered or unexported fields }
SshServer manages acceptance of and authenticating SSH connections and delegating input to a Handler for each session instantiated by the given HandlerFactory.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
func (*Shell) GetReadWrite ¶
func (s *Shell) GetReadWrite() io.ReadWriter
func (*Shell) InstanceName ¶
func (*Shell) OutputLine ¶
write string to output with adding \r\n
func (*Shell) Read ¶
Read blocks until the next line of input, such as a command, is available and returns that line. The error will be io.EOF if Control-D was pressed. If a line is given that will be the starting point for adding new input, this is for example used for tab completion return. If returned boolean is true, tab completion is requested on given line.
Click to show internal directories.
Click to hide internal directories.