I am adding a little more information that I discovered after digging out the library ...
Starting from 2.9.2, if you intend to use only the key provided in key_data, you must also specify an empty key set before loading key_data or loading some standard keys.
In my case, one of the identifier files that he was trying to download was password protected, so he asked me to use my passphrase, although my intention was not to use this identification file at all.
Using the example above in 2.9.2, you can get the same effect by doing something like this:
#!/usr/bin/env ruby require 'rubygems' require 'net/ssh' HOST = '172.20.0.31' USER = 'root' KEYS = [ "-----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEAqccvUza8FCinI4X8HSiXwIqQN6TGvcNBJnjPqGJxlstq1IfU kFa3S9eJl+CBkyjfvJ5ggdLN0S2EuGWwc/bdE3LKOWX8F15tFP0= -----END RSA PRIVATE KEY-----" ] Net::SSH.start( HOST, USER, :keys => [], :key_data => KEYS, :keys_only => TRUE) do|ssh| result = ssh.exec!('ls') puts result end
Chris reisor
source share