ruby ssh

ruby要使用到ssh的话,就得安装它
gem install net-ssh
我在下面的程序来使用ssh连接时
#!/usr/bin/env ruby
require 'net/ssh'
Net::SSH.start('host', 'user', :password => "password", :port => "port") do |ssh|
output = ssh.exec!("hostname")
puts output
end

会出现错误:
/usr/local/lib/ruby/site_ruby/1.8/net/ssh.rb:200:in `start’: host (Net::SSH::AuthenticationFailed)
from ssh.rb:7

错就错在没有加上
1 #!/usr/bin/env ruby
2 #
3 require 'net/ssh'
4
5 #host = '119.145.139.227'
6 #user = 'minix'
7 Net::SSH.start('host', 'user', :password => "password", :port => "port", :auth_methods => %w{ password }) do |ssh|
8 output = ssh.exec!("hostname")
9 puts output
10 end

留下评论