2018-10-30 17:45:30 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2022-02-25 11:34:46 +08:00
|
|
|
"blacktea.vip.cpolar.top/OrgGo/ssh"
|
2018-10-30 17:45:30 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-11-13 17:42:29 +08:00
|
|
|
config := ssh.Default.WithPassword("ubuntu")
|
|
|
|
client, err := ssh.New(config)
|
|
|
|
// client, err := ssh.NewClient("localhost", "22", "root", "ubuntu")
|
2018-10-30 17:45:30 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer client.Close()
|
|
|
|
|
|
|
|
output, err := client.Exec("uptime")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Uptime: %s\n", output)
|
|
|
|
|
|
|
|
}
|