From 86dffbafbbd08c4e1824633d2377b4ce282b41ce Mon Sep 17 00:00:00 2001 From: Josh Spence Date: Thu, 1 Feb 2024 14:45:43 +1100 Subject: [PATCH] Allow simple use of `keyboard-interactive` authentication --- internal/provider/connection.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/provider/connection.go b/internal/provider/connection.go index f7af27c..e11c312 100644 --- a/internal/provider/connection.go +++ b/internal/provider/connection.go @@ -89,6 +89,17 @@ func ConnectionFromResourceData(ctx context.Context, d *schema.ResourceData) (st password, ok := d.GetOk("conn.0.password") if ok { clientConfig.Auth = append(clientConfig.Auth, ssh.Password(password.(string))) + + // An implementation of ssh.KeyboardInteractiveChallenge that simply sends back the password for all questions. + cb := func(user, instruction string, questions []string, echos []bool) ([]string, error) { + answers := make([]string, len(questions)) + for i := range answers { + answers[i] = password.(string) + } + + return answers, nil + } + clientConfig.Auth = append(clientConfig.Auth, ssh.KeyboardInteractive(cb)) } private_key, ok := d.GetOk("conn.0.private_key")