fix ssh password auth

This commit is contained in:
Robin Appelman 2024-02-14 22:46:52 +01:00
commit b521da12c6
3 changed files with 9 additions and 9 deletions

4
Cargo.lock generated
View file

@ -1764,9 +1764,9 @@ dependencies = [
[[package]]
name = "thrussh"
version = "0.35.1"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "addf63d9ce535faca8a869a234de46c6018e9fa4b7e65597ca64e457bb8d128e"
checksum = "0eb7f634184fe86d7a9fd587d9350137508cba7b77626a7785db2ca695ebc503"
dependencies = [
"bitflags 1.3.2",
"byteorder",

View file

@ -14,7 +14,7 @@ toml = "0.8.8"
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
camino = "1.1.6"
petname = "1.1.3"
thrussh = "0.35.1"
thrussh = "0.34.0" # 0.35.1 broke password auth?
thrussh-keys = "0.22.1"
futures-util = "0.3.30"
pretty_env_logger = "0.5.0"

View file

@ -11,7 +11,7 @@ use thrussh::client::Handle;
use thrussh::*;
use thrussh_keys::key::PublicKey;
use tokio::time::{sleep, timeout};
use tracing::instrument;
use tracing::{info, instrument};
struct Client {}
@ -77,14 +77,14 @@ impl Debug for SshSession {
impl SshSession {
#[instrument(skip(auth))]
pub async fn open(ip: IpAddr, auth: &CreatedAuth) -> Result<Self, SshError> {
timeout(Duration::from_secs(5 * 60), async move {
timeout(Duration::from_secs(10 * 60), async move {
loop {
sleep(Duration::from_secs(1)).await;
sleep(Duration::from_secs(5)).await;
match SshSession::open_impl(ip, auth).await {
Ok(ssh) => return Ok(ssh),
Err(
SshError::ConnectionTimeout | SshError::Refused | SshError::Unauthorized,
) => {}
Err(err @ (SshError::ConnectionTimeout | SshError::Refused)) => {
info!(error = ?err, "ssh server not ready yes");
}
Err(e) => return Err(e),
}
}