I am trying to establish a sftp connection to my azure storage. I have a private key file which starts with
private_key = '-----BEGIN RSA PRIVATE KEY-----\nMnx......'
With this private_key, I try to establish the connection like
Net::SFTP.start('<remote-ip>', 'username',
:password => 'password',
:key_data => [ private_key ],
keys_only: true,
verify_host_key: :never) do |sftp|
data = sftp.download!("/somefile.txt")
p data
end
When I try to use this key file, I am getting an exception like
#<OpenSSL::PKey::PKeyError: Could not parse PKey: no start line>
However when I was using a key file which starts with below format
-----BEGIN OPENSSH PRIVATE KEY-----
everything was working fine.
But I want to use the new private key. What will be wrong in this code? Is there a way to specify the type of private key file to be used?