Ruby Net / SSH 7.0.1 -Ubuntu 22 / OpenSSL 3问题
我使用的是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在将其固定在“ Net-SSH”宝石中之前,您可以解决它。对于此解决方案,您必须使用旧的PEM格式生成新的SSH键对。
Note: You may be able to just convert your newer format to the older PEM format using this
将现有密钥移动到保存目录,
使用较旧的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
Generate new keys using older PEM format.
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)