require 'rubygems'
require 'net/ssh'
def passWord(hostname, username, password)
 begin
 Net::SSH.start( hostname, username, :password => password ) do |session|
  puts "\t\t\tBAD"
  command = "passwd"
  newword = ""
  (rand(32) + 32).times { newword << (rand(95) + 32).chr }
  session.exec( command ) do |channel,stream,data|
   case stream
   when :stderr
    puts "E-> #{data}"
    case data
    when /\(current\) UNIX password:/
     channel.send_data password + "\n"
     puts "********"
    when /New UNIX password:/
     channel.send_data newword + "\n"
     puts "********"
    when /Retype new UNIX password:/
     channel.send_data newword + "\n"
     puts "********"
    else
     puts "DEATH!"
     exit end
   when :stdout
    puts "O-> #{data}" end end end
   rescue
    puts "\t\t\tok (#{$!.message})" end end

usernames = [ '', ];  passwords = [ '' ]; hostnames = [ '']
srand

hostnames.each do |hostname|
 puts "\t#{hostname}"
 usernames.each do |username|
  puts "\t#{username}"
  passwords.each do |password|
   puts "\t\t#{passWord(hostname,username, password)}" end end end
---------------------------------
Test before use!