Ruby Net / SSH 7.0.1 -Ubuntu 22 / OpenSSL 3问题

发布于 2025-02-12 03:38:42 字数 726 浏览 0 评论 0原文

我使用的是Ubuntu 22,而OpenSSL 3

Ruby的Net/SSH一旦我尝试使用私钥连接,就不再工作。

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)

我没有发现任何有用的解决此问题。只要我与密码连接,这似乎可以正常工作,但是只要我使用PEM密钥就会失败。

我正在使用:

  • Ubuntu 22
  • Net-SSH 7.0.1

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏尉蓝 2025-02-19 03:38:42

在将其固定在“ Net-SSH”宝石中之前,您可以解决它。对于此解决方案,您必须使用旧的PEM格式生成新的SSH键对。

Note: You may be able to just convert your newer format to the older PEM format using this

将现有密钥移动到保存目录,

cd ~
mkdir old_keys
mv id_rsa* old_keys

使用较旧的PEM格式生成新密钥。

ssh-keygen -m PEM

这对我的Ubuntu 22.04安装Ruby(3.0.2-7ubuntu2.1)和Net-SSH(7.0.1)和OpenSSL(3.0.2-0ubuntu1.6)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文