ssh_crawler/main.go

42 lines
582 B
Go
Raw Normal View History

2017-10-20 06:10:30 +00:00
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
}