-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Arista switches, by default, allow only publickey and keyboard-interactive auth methods.
Gonir fails to create an ssh connection with the following error:
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
I fixed this error by adding ssh.KeyboardInteractive method to the ssh.ClientConfig:
// Run implements gornir.Task interface
func (t *SSHOpen) Run(ctx context.Context, logger gornir.Logger, host *gornir.Host) (gornir.TaskInstanceResult, error) {
sshConfig := &ssh.ClientConfig{
User: host.Username,
Auth: []ssh.AuthMethod{
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
answers := make([]string, len(questions))
for i := range answers {
answers[i] = host.Password
}
return answers, nil
}),
ssh.Password(host.Password),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
} // #nosec
...
ssh.KeyboardInteractive(...) simply answers with host.Password to all questions.
Please let me know if this is good enough to fix this issue, and I will submit a PR.
Metadata
Metadata
Assignees
Labels
No labels