1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 12:23:46 +03:00

ssh: try password auth before keyboard interactive

This may help for sites that use 2fac; after entering the password
correctly, the 2fac prompt may appear.
This commit is contained in:
Wez Furlong 2020-01-24 00:04:37 -08:00
parent e45bace9eb
commit 970e4a8e64

View File

@ -287,6 +287,14 @@ pub fn ssh_connect(remote_address: &str, username: &str) -> anyhow::Result<ssh2:
}
}
if !sess.authenticated() && methods.contains("password") {
let pass = password_prompt("", "Password", username, &remote_address)
.ok_or_else(|| anyhow!("password entry was cancelled"))?;
if let Err(err) = sess.userauth_password(username, &pass) {
log::error!("while attempting password auth: {}", err);
}
}
if !sess.authenticated() && methods.contains("keyboard-interactive") {
let mut prompt = Prompt {
username,
@ -298,14 +306,6 @@ pub fn ssh_connect(remote_address: &str, username: &str) -> anyhow::Result<ssh2:
}
}
if !sess.authenticated() && methods.contains("password") {
let pass = password_prompt("", "Password", username, &remote_address)
.ok_or_else(|| anyhow!("password entry was cancelled"))?;
if let Err(err) = sess.userauth_password(username, &pass) {
log::error!("while attempting password auth: {}", err);
}
}
if !sess.authenticated() {
bail!("unable to authenticate session");
}