|
func (node *Node) Connect(username string, auth ssh.AuthMethod) error { |
|
//var hostKey ssh.PublicKey |
|
|
|
// An SSH client is represented with a ClientConn. |
|
// |
|
// To authenticate with the remote server you must pass at least one |
|
// implementation of AuthMethod via the Auth field in ClientConfig, |
|
// and provide a HostKeyCallback. |
|
config := &ssh.ClientConfig{ |
|
User: username, |
|
Auth: []ssh.AuthMethod{ |
|
auth, |
|
}, |
|
//HostKeyCallback: ssh.FixedHostKey(hostKey), |
|
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { |
|
return nil |
|
}, |
|
} |
should be
func (node *Node) Connect(username string, pwd string) error {
config := &ssh.ClientConfig{
User: username,
Auth: []ssh.AuthMethod{
ssh.Password(pwd),
ssh.KeyboardInteractive(func(name, instruction string, questions []string, echos []bool) ([]string, error){
answers := make([]string, len(questions))
for i := range answers {
answers[i] = pwd
}
return answers, nil
}),
},
//HostKeyCallback: ssh.FixedHostKey(hostKey),
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
},
}
or
func (node *Node) Connect(username string, auth []ssh.AuthMethod) error {
config := &ssh.ClientConfig{
User: username,
Auth: auth,
//HostKeyCallback: ssh.FixedHostKey(hostKey),
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
},
}
ssh-web-console/src/utils/ssh_utils.go
Lines 46 to 63 in ebb9339
should be
or