github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/communicator/ssh/password.go (about)

     1  package ssh
     2  
     3  import (
     4  	"golang.org/x/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  }