Search code examples
rubymacosnet-ssh

Net::SSH fails to connect


I've written a ruby script to do some work on a remote host. Running it from a Mac with 10.6. The IP works fine with a manual ssh -l devacct 10.10.10.10, but as you can see it fails in the script.

require 'rubygems'
require 'net/ssh'

Net::SSH.start("10.10.10.10", "devacct", :password => "password1") do |ssh|
end

Fails horribly with:

/Library/Ruby/Gems/1.8/gems/net-ssh-2.1.4/lib/net/ssh/transport/session.rb:65:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)

Any ideas? :)

Kind Regards


Solution

  • Normaly this exception is thrown if the hostname can't be resolved. Make sure the ip adress you try to connect to is correct and reachable.