mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Try authentication with user_agent if possible
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user