From 8eb5a0e72ce273e6512101c127ef82b4fa56f326 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 24 Jan 2020 16:08:20 -0800 Subject: [PATCH] ssh: fix for sites that use 2fac --- src/ssh.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ssh.rs b/src/ssh.rs index 21cf4b0fc..79d2039ba 100644 --- a/src/ssh.rs +++ b/src/ssh.rs @@ -279,13 +279,17 @@ pub fn ssh_connect(remote_address: &str, username: &str) -> anyhow::Result = sess.auth_methods(&username)?.split(',').collect(); - for _ in 0..3 { if sess.authenticated() { break; } + // Re-query the auth methods on each loop as a successful method + // may unlock a new method on a subsequent iteration (eg: password + // auth may then unlock 2fac) + let methods: HashSet<&str> = sess.auth_methods(&username)?.split(',').collect(); + log::trace!("ssh auth methods: {:?}", methods); + if !sess.authenticated() && methods.contains("publickey") { if let Err(err) = sess.userauth_agent(&username) { log::info!("while attempting agent auth: {}", err);