Hello,
I am trying to run a script in several machines I have at work, to gather some information about them, such as which OS they're running, what services run on them, some configurations, etc. I have a machine on which I log before ssh-ing to any of the other machines, because of the public key setup it has. From there, I can ssh into all of the other machines without being asked for my password.
What I want to do is to automate logging onto all of these machines from that one, but the script is running on my local machine. So I just learned about ruby-ssh-gateway and am trying that, but I can't seem to get pubkey authentication to work.
I do something like this:
gateway = Net::SSH::Gateway.new('gatewaymachine', 'username', :password => 'password')
all_machines.each do |machine|
gateway.ssh(machine, 'username') do |ssh|
uname = ssh.exec!('uname -a')
puts "machine: #{machine}; OS: #{uname}"
end
end
But I get a Net::SSH::AuthenticationFailed
exception.
If, instead, I provide the password, like so:
gateway.ssh(machine, 'username', :password => 'password')
it does work, but that's not viable, since passwords are not the same across machines.
Does anyone know how I can make this work?
Thanks.