Read file over SSH

  • Thread starter Shashank Agarwal
  • Start date
S

Shashank Agarwal

Is there a way to read a file over SSH? I looked at the net/ssh library
but couldn't put together a working code.

Thanks.
 
P

Phlip

Shashank said:
Is there a way to read a file over SSH? I looked at the net/ssh library
but couldn't put together a working code.

Here's a wild guess - does it help?

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

Net::SSH.start( 'myserver', 'myname', 'mypassword' ) do |session|
session.sftp.connect do |sftp|
sftp.get_file('path/filename', 'filename')
end
end
 
J

James Dinkel

Shashank said:
Thanks for your replies. I'll look into SCP and try using SFTP. :)

Just FYI:

The terms are regularly used interchangeably, but it's "SFTP" what you
will use. "SCP" is the original file transfer protocol over ssh, but it
is not in use anymore unless you have a really really old server you are
connecting to. "SFTP" is the new protocol that in use on modern ssh
servers.
 
J

James Dinkel

Chad said:
Of course, I'm pretty sure the scp command I use is just an interface
for
the SFTP protocol that behaves the way the old scp program that used the
SCP protocol worked.

Yeah, that's probably correct. There are scp and sftp commands for
linux, but they should both use the sftp protocol (there are just usage
differences between the two programs). Ruby's scp and sftp methods may
be different though.

It's all very confusing, I know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,662
Latest member
sxarexu

Latest Threads

Top