.. highlight:: ruby ========== Net::SSH ========== http://net-ssh.rubyforge.org/ reference ========= * http://net-ssh.rubyforge.org/ssh/v2/api/index.html tips ==== * http://webos-goodies.jp/archives/51357031.html * http://www.infoq.com/articles/ruby-file-upload-ssh-intro samples ======= 基本 ---- :: #!/usr/bin/ruby require 'rubygems' require 'net/ssh' HOST='host' USER='user' Net::SSH.start(HOST, USER) do |ssh| print(ssh.exec!('ls ~')) end channel ------- :: ssh.open_channel do |channel| channel.exec("/invoke/some/command") do |ch, success| abort "could not execute command" unless success channel.on_data do |ch, data| puts "got stdout: #{data}" channel.send_data "something for stdin\n" end channel.on_extended_data do |ch, type, data| puts "got stderr: #{data}" end channel.on_close do |ch| puts "channel is closing!" end end end ssh.loop