Ruby NET :: SCP and user ports

I am trying to determine the user port for ssh connection using Net :: SCP, but so far no luck.

Here is an example of how I am trying to download a remote file from the server using the user ssh port:

require "rubygems" require 'net/scp' Net::SCP.download!("www.server.com", "user", "/opt/platform/upload/projects/file.txt", "/tmp/bb.pdf",{:password => "mypassword",:port => 22202}) 

The error message I get is:

  Errno::ECONNREFUSED: Connection refused - connect(2) 

There are no ssh connection entries in the server logs, so I assume that Net :: SCP is not using my user port.

Any tips for me?

Regards, Alex

+6
ruby ssh port
source share
2 answers

Ok, I found a solution myself.

 require "rubygems" require "net/scp" Net::SSH.start("www.myserver.com", "theuser", {:password => "whateverpwd",:port => 22212}) do |ssh| ssh.scp.download! "/opt/platform/upload/projects/my.pdf", "/tmp/bb.pdf" end 
+9
source share

I also store SSH on a non-standard port and use SCP as follows:

 Net::SCP.upload!( "foo.net", "user", the_file, the_file, :ssh => { :keys => @keys, :port => the_port } ) 

Works like a champion. I also use key based authentication, so the key parameter is passed along with the port.

+2
source share

All Articles