SSH Troubles w/ ARM64?

Background

There are two AWS EC2 machines running Ubuntu 20.04. One is an AMD64 machine the other is an ARM64 machine. Both have two processors. Both have 1 GiB of RAM. Both machines have the same key-pair for SSH.

I can shell-in to both macines from a Windows 10 client using the ssh installed in the Windows / System32 / OpenSSH directory. I assume this version came with the operating system. All good.

I can shell-in to both machines from a Windows 10 client using the ssh that comes with Git for Windows. All good.

I can shell-in from a Debian 10 client using the operating system provided ssh. All good.

Rust Program

use std::net::TcpStream;
use std::path::Path;

use ssh2::{Session, TraceFlags};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!();

    let mut session = Session::new()?;
    session.trace(
        TraceFlags::AUTH |
        TraceFlags::CONN |
        TraceFlags::ERROR |
        TraceFlags::KEX |
        TraceFlags::PUBLICKEY |
        TraceFlags::SCP |
        TraceFlags::SFTP |
        //TraceFlags::SOCKET |
        //TraceFlags::TRANS |
        TraceFlags::empty()
    );
    // amd
    //session.set_tcp_stream(TcpStream::connect("{address of the happy machine}:22")?);
    // ARM
    session.set_tcp_stream(TcpStream::connect("{address of the sad machine}:22")?);

    session.handshake()?;
    let private_key = Path::new("general-purpose.pem");
    session
        .userauth_pubkey_file("ubuntu", None, private_key, None)?;

    println!();
    Ok(())
}

Cargo.toml for Linux

[package]
name = "junk"
version = "0.1.0"
edition = "2021"

[dependencies]
ssh2 = { version = "0.9.3" }

Cargo.toml for Windows

[package]
name = "junk"
version = "0.1.0"
edition = "2021"

[dependencies]
ssh2 = { version = "0.9.3", features = ["vendored-openssl", "openssl-on-win32"] }

Troubles

The program above works correctly when connecting to the AMD64 machine when run under Windows 10. It works correctly when connecting to the AMD64 machine when run under Debian 10. All good.

The program fails when connecting to the ARM64 machine when run under Windows 10. It fails when connecting to the ARM64 machine when run under Debian 10. The error is...

Error: Error { code: Session(-18), msg: "Username/PublicKey combination invalid" }

I tried updating the operating system on the ARM64 machine. That made no difference.

Have I seriously found a bug in the libssh2 stack?

You can have a look

https://github.com/alexcrichton/ssh2-rs/issues/219

2 Likes

Thanks.

Unfortunately that doesn't fit what I'm seeing. The same key-pair (as-in the same username + file) with three ssh command line programs from two operating systems works to connect to the ARM64 machine. It can't be the credential problem suggested by yodaldevoid.

Yes, the issue has not solved this problem. I think you can try to contact him for help

Found it. AWS + ARM64 + Ubuntu 20.04 + Rust + ssh2 + RSA key fails every time.

Amazon Linux, using the same RSA key, works. An elliptical key always works. AMD64 always works. The three command line ssh always work.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.

The issue is tracked here and there is apparently a fix available.

This topic was automatically closed after 7 days. We invite you to open a new topic if you have further questions or comments.