Remote server doesn't accept password, ruby script 'net/ssh'

118 views Asked by At

I connect using ruby to the remote, pass the command, but channel.send_data ("passwd\n") dont work , I cant catch in than the reason. The password doesn't pass.

require 'rubygems' 
require 'net/ssh'
...

Net::SSH.start(@hostname, @username, :password => @password) do |session|
stdout = ""
session.exec!(@cmd) do |channel, stream, data|  
    if data =~ /Password/ 
        channel.send_data("passw\n")
    end
    stdout << data
end   
puts stdout
session.close 
end
0

There are 0 answers