2

I'm using Ubuntu 22 and OpenSSL 3

Ruby's Net/SSH is not working any longer as soon as I'm trying to connect using private keys.

Net::SSH.start X.X.X.X, "root"
/.rvm/gems/ruby-3.1.2/gems/net-ssh-7.0.1/lib/net/ssh/authentication/key_manager.rb:168:in `rescue in sign': the given identity is known, but the private key could not be loaded: OpenSSL::PKey::PKeyError (rsa#set_key= is incompatible with OpenSSL 3.0) (Net::SSH::Authentication::KeyManagerError)                     
/.rvm/gems/ruby-3.1.2/gems/net-ssh-7.0.1/lib/net/ssh/buffer.rb:266:in `set_key': rsa#set_key= is incompatible with OpenSSL 3.0 (OpenSSL::PKey::PKeyError)

I haven't found anything useful to fix this. This seems to work as long as I'm connecting with a Password, but as soon as I'm using a PEM key this fails.

I'm using:

  • Ubuntu 22
  • Net-SSH 7.0.1
1
  • The error clearly tells you the library is incompatible with OpenSSL 3. Recompile Ruby with a supported OpenSSL library. Commented Jul 4, 2022 at 3:35

1 Answer 1

8

Until this is fixed in the 'net-ssh' gem you can workaround it. For this solution you'll have to generate a new ssh key pair using the older PEM format.

Note: You may be able to just convert your newer format to the older PEM format using this https://unix.stackexchange.com/questions/638043/how-to-convert-rfc4716-private-keys-to-pem-private-keys article, but I didn't test it. I did test and am currently using the solution below.

Move your existing keys to a save directory

cd ~
mkdir old_keys
mv id_rsa* old_keys

Generate new keys using older PEM format.

ssh-keygen -m PEM

This worked for me on my Ubuntu 22.04 install running Ruby (3.0.2-7ubuntu2.1) and net-ssh (7.0.1) and openssl (3.0.2-0ubuntu1.6)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.