Ruby SFTP issue

659 Views Asked by At

I am brand new to Ruby programming. Shortly after completing some free online lessons, I decided I wanted to complete a real world practical script.

I want to automate some file transfers using the SFTP protocol. I have installed the required gems (net-ssh, and net-sftp). But it appears I cannot connect to the server I am developing against. I am only trying to connect to the server with my script. I am not performing any SFTP commands. I have the following code:

    require 'rubygems'
    require 'net/ssh'
    require 'net/sftp'

    Net::SFTP.start('server_ip_address','username', password => 'password') do |sftp|
        puts "Connected!"
    end

I keep getting the following error:

C:/Ruby22/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.3.beta1/lib/net/ssh/transport/ses sion.rb:71:in `initialize': A connection attempt failed because the connected pa rty did not properly respond after a period of time, or established connection f ailed because connected host has failed to respond. - connect(2) for "(server_name)" port 22 (Errno::ETIMEDOUT)

I am able to connect to the SFTP server using FileZilla from my machine. I am developing from a Windows 7 64bit laptop, Ruby 2.2.0 installed.

Does anybody have any ideas on why I cannot connect to the remote server?

This is also my very first question on StackOverflow. If I did not list enough information, please let me know.

Thanks in advance.

0

There are 0 best solutions below