Skip to content

Commit

Permalink
Use PasswordCallback instead of Password for ssh
Browse files Browse the repository at this point in the history
Currently asking for login password, even if not supported by
the ssh server. So wait with prompt until actually requested.

Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Dec 4, 2020
1 parent 70284b1 commit aaade40
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/bindings/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (
authMethods = append(authMethods, ssh.Password(pw))
}
if len(authMethods) == 0 {
pass, err := terminal.ReadPassword("Login password:")
if err != nil {
return Connection{}, err
callback := func() (string, error) {
pass, err := terminal.ReadPassword("Login password:")
return string(pass), err
}
authMethods = append(authMethods, ssh.Password(string(pass)))
authMethods = append(authMethods, ssh.PasswordCallback(callback))
}

port := _url.Port()
Expand Down

0 comments on commit aaade40

Please sign in to comment.