github.com/jerryclinesmith/packer@v0.3.7/communicator/ssh/password.go (about)

     1  package ssh
     2  
     3  import "log"
     4  
     5  // An implementation of ssh.ClientPassword so that you can use a static
     6  // string password for the password to ClientAuthPassword.
     7  type Password string
     8  
     9  func (p Password) Password(user string) (string, error) {
    10  	return string(p), nil
    11  }
    12  
    13  // An implementation of ssh.ClientKeyboardInteractive that simply sends
    14  // back the password for all questions. The questions are logged.
    15  type PasswordKeyboardInteractive string
    16  
    17  func (p PasswordKeyboardInteractive) Challenge(user, instruction string, questions []string, echos []bool) ([]string, error) {
    18  	log.Printf("Keyboard interactive challenge: ")
    19  	log.Printf("-- User: %s", user)
    20  	log.Printf("-- Instructions: %s", instruction)
    21  	for i, question := range questions {
    22  		log.Printf("-- Question %d: %s", i+1, question)
    23  	}
    24  
    25  	// Just send the password back for all questions
    26  	answers := make([]string, len(questions))
    27  	for i, _ := range answers {
    28  		answers[i] = string(p)
    29  	}
    30  
    31  	return answers, nil
    32  }