mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
ec85fb1960
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
29 lines
793 B
Go
29 lines
793 B
Go
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
|
|
}
|
|
}
|