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.
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.
On 2 Aug, 19:29, Shashank A. [email protected] wrote:
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.
Posted viahttp://www.ruby-forum.com/.
You’re probably interested in Net::SCP:
http://net-ssh.rubyforge.org/scp/v1/api/index.html
Shashank A. wrote:
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
Thanks for your replies. I’ll look into SCP and try using SFTP. 
Shashank A. wrote:
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.
On Sun, Aug 03, 2008 at 03:23:53AM +0900, Phlip wrote:
Net::SSH.start( ‘myserver’, ‘myname’, ‘mypassword’ ) do |session|
session.sftp.connect do |sftp|
sftp.get_file(‘path/filename’, ‘filename’)
end
end
I actually have need of some net/ssh help, too, though I don’t need help
with basic implementation. That part was easy, with the examples I’ve
found.
What I need is some way to securely store user names and passwords for
later user in the Ruby SSH client, so that I don’t have to hard-code the
user name and password, store the actual user name and password in some
file, or have the user enter them every single time he/she uses the
application. Would you please point me at relevant documentation and/or
examples, or provide some of your own for me if that’s easier?
I haven’t looked at key-based authentication, but that’s something else
I’ll be looking into as well.
On Mon, Aug 04, 2008 at 09:27:11AM +0900, James D. wrote:
Shashank A. wrote:
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.
I use scp all the time, when I want to just send or receive a single
file
and know exactly where the file is located and where it’s going without
having to search through directories.
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.
Chad P. wrote:
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs