# Net::SSH is unable to use my RSA Key

**URL:** <https://www.ruby-forum.com/t/net-ssh-is-unable-to-use-my-rsa-key/193495>\
**Category:** Ruby\
**Created:** [August 18, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/net-ssh-is-unable-to-use-my-rsa-key/193495 "2010-08-18T19:16:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@marcos](https://www.ruby-forum.com/u/marcos)\
**Post date:** [August 18, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/net-ssh-is-unable-to-use-my-rsa-key/193495/1 "2010-08-18T19:16:24Z")

</div>

Hi all,

I’m currently using ruby 1.9.1p429 and net-ssh-2.0.23

When I try to use Net:SSH with the following example:  
#!/usr/bin/env ruby  
require ‘net/ssh’  
Net::SSH.start(‘examplehost’, ‘user’, :password =\> “passwordtest”) do  
|ssh|  
output = ssh.exec!(“whoami”)  
puts output  
end

it always throws me the following exception:  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/key\_factory.rb:62:in  
`initialize': Neither PUB key nor PRIV key:: nested asn1 error (OpenSSL::PKey::RSAError) from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/key_factory.rb:62:in`new’  
from  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/key\_factory.rb:62:in  
`load_data_private_key' from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/key_factory.rb:39:in`load\_private\_key’  
from  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/key\_manager.rb:113:in  
`block in each_identity' from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/key_manager.rb:101:in`each’  
from  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/key\_manager.rb:101:in  
`each_identity' from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/methods/publickey.rb:19:in`authenticate’  
from  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/session.rb:68:in  
`block in authenticate' from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/session.rb:61:in`each’  
from  
/usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh/authentication/session.rb:61:in  
`authenticate' from /usr/lib/ruby/gems/1.9/gems/net-ssh-2.0.23/lib/net/ssh.rb:183:in`start’

When I delete my id\_rsa Key it asks me for password authentication and  
then it works. But unfortunately not which pubkey authentication.

As far as I remember, in the past with ruby 1.8.6 that worked already.

Any hints would be appreciated.

Thanks,  
Marco
