Try authentication with user_agent if possible
@@ -225,9 +225,15 @@ impl FileTransfer for SftpFileTransfer {
format!("{}", err),
));
}
- // Try authentication
+ let username: String = match username {
+ Some(u) => u.clone(),
+ None => String::from(""),
+ };
+ // Try authenticating with user agent
+ if let Err(_) = session.userauth_agent(username.as_str()) {
+ // Try authentication with password then
if let Err(err) = session.userauth_password(
- username.unwrap_or(String::from("")).as_str(),
+ username.as_str(),
password.unwrap_or(String::from("")).as_str(),
) {
return Err(FileTransferError::new_ex(
@@ -235,6 +241,7 @@ impl FileTransfer for SftpFileTransfer {
format!("{}", err),
));
}
+ }
// Set blocking to true
session.set_blocking(true);
// Get Sftp client
