github.com/adamar/terraform@v0.2.2-0.20141016210445-2e703afdad0e/helper/ssh/password.go (about)

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