SSHTunnel/Tunnel/KeyboardInteractiveChallenge.go
Thorsten Sommer a16b99af6e Version 1.2.0
2015-09-28 15:28:11 +02:00

36 lines
882 B
Go

package Tunnel
import (
"log"
)
// Another auth. method.
func KeyboardInteractiveChallenge(user, instruction string, questions []string, echos []bool) (answers []string, err error) {
// Log all the provided data:
log.Println(`User: ` + user)
log.Println(`Instruction: ` + instruction)
log.Println(`Questions:`)
for q := range questions {
log.Println(q)
}
// How many questions are asked?
countQuestions := len(questions)
if countQuestions == 1 {
// We expect that in this case (only one question is asked), that the server want to know the password ;-)
answers = make([]string, countQuestions, countQuestions)
answers[0] = callbackPassword
} else if countQuestions > 1 {
// After logging, this call will exit the whole program:
log.Fatalln(`The SSH server is asking multiple questions! This program cannot handle this case.`)
}
err = nil
return
}