Skip to content

Commit

Permalink
try interactive at last (#3886)
Browse files Browse the repository at this point in the history
  • Loading branch information
davies authored and SandyXSD committed Aug 31, 2023
1 parent fff2454 commit 41aaa92
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/object/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (f *sftpStore) ListAll(prefix, marker string) (<-chan Object, error) {
return listed, nil
}

func SshInteractive(user, instruction string, questions []string, echos []bool) (answers []string, err error) {
func sshInteractive(user, instruction string, questions []string, echos []bool) (answers []string, err error) {
if len(questions) == 0 {
fmt.Print(user, instruction)
} else {
Expand Down Expand Up @@ -476,10 +476,7 @@ func newSftp(endpoint, username, pass, token string) (ObjectStorage, error) {
username = unescape(username)
var auth []ssh.AuthMethod
if pass != "" {
pass = unescape(pass)
auth = append(auth, ssh.Password(pass))
} else {
auth = append(auth, ssh.KeyboardInteractive(SshInteractive))
auth = append(auth, ssh.Password(unescape(pass)))
}

var signers []ssh.Signer
Expand Down Expand Up @@ -530,6 +527,10 @@ func newSftp(endpoint, username, pass, token string) (ObjectStorage, error) {
auth = append(auth, ssh.PublicKeys(signers...))
}

if pass == "" {
auth = append(auth, ssh.KeyboardInteractive(sshInteractive))
}

config := &ssh.ClientConfig{
User: username,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Expand Down

0 comments on commit 41aaa92

Please sign in to comment.