I\'m trying to write a Ruby script that will ssh over to a server, run a given command, and fetch the output from it. Here\'s what I\'ve got so far, mostly adapted from the Prog
For this I recommend using the net-ssh gem: sudo gem install net-ssh: http://net-ssh.rubyforge.org/ssh/v2/api/index.html
sudo gem install net-ssh
The code goes a little like this:
require 'rubygems' require 'net/ssh' Net::SSH.start('your-server', 'username', :password => "password") do |ssh| puts ssh.exec!("ls -la") end