Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'net/ssh/multi'
- require 'socket'
- HOSTLIST = ['1.2.3.4','127.0.0.1','128.0.0.1']
- USERLIST = ['user','user']
- PASSWORD = ['userpegase','userpegase']
- Net::SSH::Multi.start do |session|
- HOSTLIST.each_with_index do |session_server,index|
- begin
- session.use session_server , :user => USERLIST[index] , :password => PASSWORD[index], :timeout => 2
- session.exec 'pwd' do |ch, stream, data|
- puts "[#{ch[session]} : #{stream}] - #{data}"
- end
- rescue Timeout::Error
- puts "+++++++ Timed out"
- rescue Net::SSH::ConnectionTimeout
- puts "+++++++ Timed out"
- rescue Errno::EHOSTUNREACH
- puts "+++++++ Host unreachable"
- rescue Errno::ECONNREFUSED
- puts "+++++++ Connection refused"
- rescue Net::SSH::AuthenticationFailed
- puts "+++++++ Authentification failure "
- rescue SocketError
- puts "Got socket error: #"
- end
- end
- session.loop
- end
Add Comment
Please, Sign In to add comment