Hi,
I need to automate the ssh connection for that i wrote the small snippet
but the error shows its not able to communicate with the remote machine
using the below code. Please provide the solution.

------------
Note:
1) Telnet service is not available on the remote machine
2) I am able to execute the command manually using Putty
------------


###------------
##My code:
###-----------

#!/usr/bin/ruby

require 'rubygems'
require 'net/ssh'

def SetSsh(command)

Net::SSH.start($ipdddr, "username", :password => "password") do|ssh|
result = ssh.exec!(command)
puts "result = #{result}"
end
end

Main program execution
SetSsh("ls -l")
##########-End of File.

----------------------------

Error Which i received:

C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh/transport/session.rb:67:in
initialize': No connection could be made because the target machine
actively refused it. - connect(2) (Errno::ECONNREFUSED)
from
C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh/transport/session.rb:67:inopen'
from
C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh/transport/session.rb:67:in
initialize'
from C:/Ruby187/lib/ruby/1.8/timeout.rb:53:intimeout'
from C:/Ruby187/lib/ruby/1.8/timeout.rb:101:in timeout'
from
C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh/transport/session.rb:67:ininitialize'
from
C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh.rb:186:in
new'
from
C:/Ruby187/lib/ruby/gems/1.8/gems/net-ssh-2.6.1/lib/net/ssh.rb:186:instart'
from File_name.rb:49:in `SetSsh'
from File_name.rb:338
------------------------------

-- 
Posted via http://www.ruby-forum.com/.