Russh: Unknown server key

⚓ Rust    📅 2026-05-17    👤 surdeus    👁️ 1      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Russh: Unknown server key

Hello! :slightly_smiling_face: 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 :sweat_smile:. But it's a long story :slightly_smiling_face: (Maybe I will tell about this on my website... For my regular readers :thinking:). 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 :thinking:. But it doesn't matter :slightly_smiling_face:

So, how can I solve Unknown server key issue? :slightly_smiling_face:

Thanks... in... Advance! :grin:

7 posts - 2 participants

Read full topic

🏷️ Rust_feed