Try authentication with user_agent if possible

This commit is contained in:
ChristianVisintin
2020-12-05 15:50:26 +01:00
parent 2e7acd4aba
commit 1ece4eabfd

View File

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