forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
password.go
28 lines (23 loc) · 793 Bytes
/
password.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ssh
import (
"log"
"golang.org/x/crypto/ssh"
)
// An implementation of ssh.KeyboardInteractiveChallenge that simply sends
// back the password for all questions. The questions are logged.
func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge {
return func(user, instruction string, questions []string, echos []bool) ([]string, error) {
log.Printf("Keyboard interactive challenge: ")
log.Printf("-- User: %s", user)
log.Printf("-- Instructions: %s", instruction)
for i, question := range questions {
log.Printf("-- Question %d: %s", i+1, question)
}
// Just send the password back for all questions
answers := make([]string, len(questions))
for i := range answers {
answers[i] = string(password)
}
return answers, nil
}
}