Establish SFTP connection

Hi ,

I am trying to connect to a SFTP server on my machine running using
WinSSHD. The port on which it is running is 22. I am unable to make a
connection to this port using ruby Net:sftp and Net:SSH libraries.
Here are both the codes:

#Option 1
require ‘net/sftp’
Net::SFTP.start(‘192.168.1.3’,:port =>22,:user=> ‘sri’, :password =>
‘root’) do |sftp|
sftp.upload!(“c:\u.txt”, “/”)
end

=============================================================

=============================================================
#option 2
require ‘net/ssh’
require ‘net/sftp’

Net::SSH.start
(‘192.168.1.3’,:password=>‘root’,:port=>22,:username=>‘sri’) do |ssh|
ssh.sftp.connect do |sftp|
Dir.foreach(’.’) do |file|
puts file
end
end
end

In both above examples i see that connection is taking place at random
ports instead of 22. Is something wrong with the code. Why it is not
taking the port i have specified??

Pls help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs