net-ssh / net-ssh

Pure Ruby implementation of an SSH (protocol 2) client
http://net-ssh.github.io/net-ssh
MIT License
980 stars 444 forks source link

Error: EVP_PKEY_sign: passed a null parameter #899

Open a-m-a-r-t-i-n opened 1 year ago

a-m-a-r-t-i-n commented 1 year ago

Expected behavior

To be able to connect to a server via a ECDSA ssh key

Actual behavior

When using an ecdsa key Ive generated I can ssh to my test server without problem, but the snippet of code below fails using the same key & user. When I use an rsa key and connect to the same server the code works.

System configuration

Example App

require 'net/ssh'

Net::SSH.start(
  'myserver', 
  'user',
  :keys => [ "~/.ssh/id_ecdsa" ],
 ) do |session|
   session.exec "uptime"
end

Error:

/opt/ruby/3.1.0/openssl/pkey.rb:254:in `rescue in dsa_sign_asn1': EVP_PKEY_sign: passed a null parameter (OpenSSL::PKey::ECError)
        from /opt/ruby/3.1.0/openssl/pkey.rb:251:in `dsa_sign_asn1'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/transport/openssl.rb:246:in `ssh_do_sign'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/key_manager.rb:174:in `sign'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/methods/publickey.rb:60:in `authenticate_with_alg'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/methods/publickey.rb:126:in `authenticate_with'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/methods/publickey.rb:19:in `block in authenticate'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/key_manager.rb:131:in `block in each_identity'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/key_manager.rb:128:in `each'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/key_manager.rb:128:in `each_identity'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/methods/publickey.rb:18:in `authenticate'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/session.rb:87:in `block in authenticate'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/session.rb:71:in `each'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh/authentication/session.rb:71:in `authenticate'
        from /opt/ruby/gems/3.1.0/gems/net-ssh-7.0.1/lib/net/ssh.rb:254:in `start'
        from ./try-ecdsa-connect.rb:9:in `<main>'