project address
go-webssh
go version webssh
core
This item code from https://github.com/dejavuzhou/felix , just inside the webssh out, modified a bit, made webssh, it is noted. There is a need to view this item.
installation
Modify the information core / ssh.go inside the account password address. You can also modify itself as a key to log on.
func NewSshClient() (*ssh.Client, error) {
config := &ssh.ClientConfig{
Timeout: time.Second * 5,
User: "root",
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //这个可以, 但是不够安全
//HostKeyCallback: hostKeyCallBackFunc(h.Host),
}
//if h.Type == "password" {
config.Auth = []ssh.AuthMethod{ssh.Password("123456")}
//} else {
// config.Auth = []ssh.AuthMethod{publicKeyAuthFunc(h.Key)}
//}
addr := fmt.Sprintf("%s:%d", "192.168.100.200", 22)
c, err := ssh.Dial("tcp", addr, config)
if err != nil {
return nil, err
}
return c, nil
}
go install
go run main.go
front end
I tested with was a vue, you can put your items inside. In the web / vue / index.vue inside remember modified rear end 32 of the row address
You can also get hold of their own ordinary index.html, put a websocket connection.
web / html is a generic version of index.html, not tested for reference purposes only!