Documentation ¶
Index ¶
- Variables
- type SSHKind
- type SSHKindSRL
- func (sk *SSHKindSRL) Commit(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindSRL) Compare(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindSRL) Discard(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindSRL) PromptParse(s *SSHTransport, in *string) *SSHReply
- func (sk *SSHKindSRL) Start(s *SSHTransport, transaction bool) error
- type SSHKindVRSROS
- func (sk *SSHKindVRSROS) Commit(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindVRSROS) Compare(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindVRSROS) Discard(s *SSHTransport) (*SSHReply, error)
- func (sk *SSHKindVRSROS) PromptParse(s *SSHTransport, in *string) *SSHReply
- func (sk *SSHKindVRSROS) Start(s *SSHTransport, transaction bool) error
- type SSHReply
- type SSHSession
- type SSHTransport
- type SSHTransportOption
Constants ¶
This section is empty.
Variables ¶
var DebugCount int
Debug count
Functions ¶
This section is empty.
Types ¶
type SSHKind ¶
type SSHKind interface { // Start a config transaction Start(s *SSHTransport, transaction bool) error // Commit a config transaction Commit(s *SSHTransport) (*SSHReply, error) // Commit a config transaction Compare(s *SSHTransport) (*SSHReply, error) // Prompt parsing function Discard(s *SSHTransport) (*SSHReply, error) // Prompt parsing function // // This function receives string, split by the delimiter and should ensure this is a valid prompt // Valid prompt, strip the prompt from the result and add it to the prompt in SSHReply // // A default implementation is promptParseNoSpaces, which simply ensures there are // no spaces between the start of the line and the # PromptParse(s *SSHTransport, in *string) *SSHReply }
An interface to implement kind specific methods for transactions and prompt checking each kind should implement this interface
type SSHKindSRL ¶
type SSHKindSRL struct{}
implements SShKind
func (*SSHKindSRL) Commit ¶
func (sk *SSHKindSRL) Commit(s *SSHTransport) (*SSHReply, error)
func (*SSHKindSRL) Compare ¶
func (sk *SSHKindSRL) Compare(s *SSHTransport) (*SSHReply, error)
func (*SSHKindSRL) Discard ¶
func (sk *SSHKindSRL) Discard(s *SSHTransport) (*SSHReply, error)
func (*SSHKindSRL) PromptParse ¶
func (sk *SSHKindSRL) PromptParse(s *SSHTransport, in *string) *SSHReply
func (*SSHKindSRL) Start ¶
func (sk *SSHKindSRL) Start(s *SSHTransport, transaction bool) error
type SSHKindVRSROS ¶
type SSHKindVRSROS struct{}
implements SShKind
func (*SSHKindVRSROS) Commit ¶
func (sk *SSHKindVRSROS) Commit(s *SSHTransport) (*SSHReply, error)
func (*SSHKindVRSROS) Compare ¶
func (sk *SSHKindVRSROS) Compare(s *SSHTransport) (*SSHReply, error)
func (*SSHKindVRSROS) Discard ¶
func (sk *SSHKindVRSROS) Discard(s *SSHTransport) (*SSHReply, error)
func (*SSHKindVRSROS) PromptParse ¶
func (sk *SSHKindVRSROS) PromptParse(s *SSHTransport, in *string) *SSHReply
func (*SSHKindVRSROS) Start ¶
func (sk *SSHKindVRSROS) Start(s *SSHTransport, transaction bool) error
type SSHReply ¶
type SSHReply struct{ Node, Source, Prompt, Command, Response string }
The SSH reply, executed command and the prompt
type SSHSession ¶
func NewSSHSession ¶
func NewSSHSession(host string, sshConfig *ssh.ClientConfig) (*SSHSession, error)
Create a new SSH session (Dial, open in/out pipes and start the shell) pass the authntication details in sshConfig
func (*SSHSession) Close ¶
func (ses *SSHSession) Close() error
type SSHTransport ¶
type SSHTransport struct { // Contains the first read after connecting LoginMessage *SSHReply // SSH parameters used in connect // default: 22 Port int // Keep the target for logging Target string // SSH Options // required! SSHConfig *ssh.ClientConfig // Character to split the incoming stream (#/$/>) // default: # PromptChar string // Kind specific transactions & prompt checking function K SSHKind // contains filtered or unexported fields }
SSHTransport setting needs to be set before calling Connect() SSHTransport implements the Transport interface
func NewSSHTransport ¶
func NewSSHTransport(node *types.NodeConfig, options ...SSHTransportOption) (*SSHTransport, error)
func (*SSHTransport) Close ¶
func (t *SSHTransport) Close() error
Close the Session and channels Part of the Transport interface
func (*SSHTransport) Connect ¶
func (t *SSHTransport) Connect(host string) error
Connect to a host Part of the Transport interface
func (*SSHTransport) InChannel ¶
func (t *SSHTransport) InChannel()
Creates the channel reading the SSH connection
The first prompt is saved in LoginMessages ¶
- The channel read the SSH session, splits on PromptChar
- Uses SSHKind's PromptParse to split the received data in *result* and *prompt* parts (if no valid prompt was found, prompt will simply be empty and result contain all the data)
- Emit data
type SSHTransportOption ¶
type SSHTransportOption func(*SSHTransport) error
func HostKeyCallback ¶
func HostKeyCallback(callback ...ssh.HostKeyCallback) SSHTransportOption
Add a basic username & password to a config Will initialize the config if required
func WithUserNamePassword ¶
func WithUserNamePassword(username, password string) SSHTransportOption
Add username & password authentication