rust-lang / rust-lang/ssh2-rs

Not support ECDSA key files to login a Ubuntu Server

Open
#321 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
566
Forks
163
Avg merge
4h 51m
Merged PRs (30d)
2

Description

System:

Windows 11 -> Ubuntu 24.04 LTS
ii openssh-server 1:9.6p1-3ubuntu13.4 amd64 secure shell (SSH) server, for secure access from remote machines

version:

ssh2 = "0.9.4"

code

    pub fn login(&mut self) {
        /* 登录 */
        let tcp = TcpStream::connect(format!("{}:{}", self.host, self.port)).expect(format!("TCP创建失败: {}:{}", self.host, self.port).as_str());
        self.session.set_tcp_stream(tcp);
        self.session.handshake().expect(format!("TCP握手失败: {}:{}", self.host, self.port).as_str());

        if self.prikey.chars().count() > 0 {
            // 使用证书认证
            let prikeyf = Path::new(self.prikey.as_str());
            self.session.userauth_pubkey_file(&self.username, None, prikeyf, Some(&self.password)).expect("证书认证失败");
        } else {
            // 使用密码认证
            self.session.userauth_password(&self.username, &self.password).expect("密码认证失败");
        }
        assert!(self.session.authenticated());
    }

If I use an RSA key file, it works well, but when I use an ECDSA key file, it runs into an error like this:

证书认证失败: Error { code: Session(-1), msg: "unknown error" }
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\result.rs:1654
   3: enum2$<core::result::Result<tuple$<>,ssh2::error::Error> >::expect<tuple$<>,ssh2::error::Error>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\result.rs:1034
   4: sync_ssh_dir::sshdirsyncer::SshdirSyncer::login
             at .\src\sshdirsyncer.rs:93
   5: sync_ssh_dir::sshdirsyncer::SshdirSyncer::run_sync
             at .\src\sshdirsyncer.rs:260
   6: sync_ssh_dir::main
             at .\src\main.rs:14
   7: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250
   8: core::hint::black_box
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\hint.rs:337
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\sync_ssh_dir.exe` (exit code: 101)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure through ssh2 0.9.4's userauth_pubkey_file entry point using an ECDSA key against Ubuntu 24.04, comparing it with the working RSA case. Trace the reported failure from the call at src/sshdirsyncer.rs:93 and determine whether ECDSA authentication can complete successfully; no repository test is mentioned in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, ubuntu
Domain
authentication, networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.