Russh: Unknown server key
⚓ Rust 📅 2026-05-17 👤 surdeus 👁️ 1Hello!
I have some problem that I want you to help me to fix.
Here's the part of my code:
use russh::client;
use std::sync::Arc;
...
struct SshClient {}
impl client::Handler for SshClient {
type Error = russh::Error;
}
...
impl App {
...
let runtime = tokio::runtime::Runtime::new().map_err(|e| format!("Failed to create async runtime: {e}"))?;
runtime.block_on(async {
start_ssh_tunnel(password).await
}).map_err(|e| format!("Failed to create SSH tunnel: {e}"))?;
...
}
...
async fn start_ssh_tunnel(password: String) -> Result<(), Box<dyn std::error::Error>> {
let ssh_client = SshClient {};
let mut session = russh::client::connect(
Arc::new(client::Config::default()),
format!("{}:{}", "example.com", 22),
ssh_client
).await?;
session.authenticate_password("someuser", password).await?;
Ok(())
}
So, when I tries to launch the app, I gets the error:
Failed to create SSH tunnel: Unknown server key
And... Yeap! Some parts of the code was be written by AI, honestly
. But it's a long story
(Maybe I will tell about this on my website... For my regular readers
). Here's only the start of the app was be written by it. But... start_ssh_tunnel function and the client "Handler" (that tiny-tiny-tiny thing) was be written by me
. But it doesn't matter ![]()
So, how can I solve Unknown server key issue? ![]()
Thanks... in... Advance! ![]()
7 posts - 2 participants
🏷️ Rust_feed