github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/communicator/ssh/password.go (about) 1 package ssh 2 3 import ( 4 "log" 5 6 "golang.org/x/crypto/ssh" 7 ) 8 9 // An implementation of ssh.KeyboardInteractiveChallenge that simply sends 10 // back the password for all questions. The questions are logged. 11 func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge { 12 return func(user, instruction string, questions []string, echos []bool) ([]string, error) { 13 log.Printf("Keyboard interactive challenge: ") 14 log.Printf("-- User: %s", user) 15 log.Printf("-- Instructions: %s", instruction) 16 for i, question := range questions { 17 log.Printf("-- Question %d: %s", i+1, question) 18 } 19 20 // Just send the password back for all questions 21 answers := make([]string, len(questions)) 22 for i := range answers { 23 answers[i] = string(password) 24 } 25 26 return answers, nil 27 } 28 }