Documentation ¶
Overview ¶
SSH Client can login to multiple devices.
Example (ExecCommandsAdvaned) ¶
// List of initial commands that dont need any outputs initcmd := []string{ "set cli op-command-xml-output on", } // List of the commands should be sent to the devices listCMDs := []string{ "test routing fib-lookup virtual-router default ip 1.1.1.1", "show interface ethernet1/1 | match zone", "exit", } sshconfig := InsecureClientConfig("admin", "admin", 5*time.Second) rhc := CreateRhConfig("192.168.1.1", "tcp", "22") result, err := ExecCommandsAdvaned(rhc, initcmd, listCMDs, sshconfig) if err != nil { log.Fatal(err) } for _, item := range result { fmt.Println(item.Cmd) fmt.Println(item.Result) }
Output:
Example (ExecCommandsSimple) ¶
// List of initial commands that dont need any outputs initcmd := "set cli op-command-xml-output on" sshconfig := InsecureClientConfig("admin", "admin", 5*time.Second) rhc := CreateRhConfig("192.168.1.1", "tcp", "22") result, err := ExecCommandsSimple(rhc, listCMDs, sshconfig) if err != nil { log.Fatal(err) } fmt.Println(result)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecSimple ¶
ExecSimple uses ssh.Dial to dials to remote-host, applies commands mentioned in 'cmds'. This function needs remote-host IP, protocol and port which gets from RhConfig and also ssh.ClientConfig It returns a string as result
func InsecureClientConfig ¶
func InsecureClientConfig(userStr, passStr string, t time.Duration) *ssh.ClientConfig
InsecureClientConfig ...
Types ¶
type CmdResults ¶
CmdResults ... Command Result
func ExecAdvanced ¶
func ExecAdvanced(rhc RhConfig, initcmds, cmds []string, sshconfig *ssh.ClientConfig) ([]CmdResults, error)
ExecAdvanced uses ssh.Dial to dials to remote-host, applies what is mentioned in 'initcmds' as initial commands, then 'cmds' as commands. This function needs remote-host IP, protocol and port which gets from RhConfig and also ssh.ClientConfig It returns a CmdResults
Click to show internal directories.
Click to hide internal directories.