rust-lang / rust-lang/ssh2-rs

```userauth_pubkey_memory()``` not working.

Open
#284 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi I am facing an issue with ssh2 crate, while trying to login to aws EC2 instance using the private key.
The following code is panicking.

sess.userauth_pubkey_memory(&username, None, private_key, None).unwrap();

With following error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: Session(-14), msg: "Error parsing PEM: offset out of bounds" }', src/main.rs:71:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

using version: 0.9.4
I am able to login to the ec2 instance while using the userauth_pubkey_file(), by providing the path to the privatekey file

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

Start by reproducing the panic at the userauth_pubkey_memory call in src/main.rs:71:69, using the reported ssh2 0.9.4 version and private key. Compare its behavior with userauth_pubkey_file(), and consider the PEM parsing error resolved when in-memory authentication accepts the same key that file-based authentication accepts.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.