42 lines
582 B
Go
42 lines
582 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"git.loafle.net/overflow/ssh_crawler/ssh"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
|
||
|
func main() {
|
||
|
|
||
|
const ip = "192.168.1.15"
|
||
|
const port = "22"
|
||
|
const user = "administrator"
|
||
|
const pw = "!@#$qwer1234"
|
||
|
|
||
|
client, err := connectSSH(ip, port, user, pw)
|
||
|
if err != nil {
|
||
|
fmt.Errorf("%s", err)
|
||
|
}
|
||
|
|
||
|
res, err := client.CPUStat()
|
||
|
if err != nil {
|
||
|
fmt.Errorf("%s", err)
|
||
|
}
|
||
|
fmt.Printf("%s", res)
|
||
|
|
||
|
client.Close()
|
||
|
}
|
||
|
|
||
|
func connectSSH(ip, port, user, pw string) (*ssh.SSHClient, error){
|
||
|
client, err := ssh.New(ip, port, user, pw)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return client, nil
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|