alexcrichton / ssh2-rs

Rust bindings for libssh2
https://docs.rs/ssh2
Apache License 2.0
467 stars 142 forks source link

```userauth_pubkey_memory()``` not working. #284

Open Strange21 opened 1 year ago

Strange21 commented 1 year ago

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