mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-19 09:43:17 +00:00
If we have a sftp key file in the environment/preferences, then don't attempt a password login to avoid bad login errors.
This commit is contained in:
@@ -199,6 +199,7 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor
|
||||
if username != "" {
|
||||
username = username[:len(username) - 1]
|
||||
}
|
||||
keyFile := GetPasswordFromPreference(preference, "ssh_key_file")
|
||||
|
||||
password := ""
|
||||
passwordCallback := func() (string, error) {
|
||||
@@ -219,7 +220,6 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor
|
||||
}
|
||||
}
|
||||
|
||||
keyFile := ""
|
||||
publicKeysCallback := func() ([]ssh.Signer, error) {
|
||||
LOG_DEBUG("SSH_PUBLICKEY", "Attempting public key authentication")
|
||||
|
||||
@@ -273,10 +273,19 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor
|
||||
}
|
||||
|
||||
authMethods := [] ssh.AuthMethod {
|
||||
}
|
||||
passwordAuthMethods := [] ssh.AuthMethod {
|
||||
ssh.PasswordCallback(passwordCallback),
|
||||
ssh.KeyboardInteractive(keyboardInteractive),
|
||||
}
|
||||
keyFileAuthMethods := [] ssh.AuthMethod {
|
||||
ssh.PublicKeysCallback(publicKeysCallback),
|
||||
}
|
||||
if keyFile!="" {
|
||||
authMethods = append(keyFileAuthMethods,passwordAuthMethods...)
|
||||
} else {
|
||||
authMethods = append(passwordAuthMethods,keyFileAuthMethods...)
|
||||
}
|
||||
|
||||
if RunInBackground {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user