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 via http://www.ruby-forum.com/.
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 via http://www.ruby-forum.com/.
You're probably interested in Net::SCP:
http://net-ssh.rubyforge.org/scp/v1/api/index.html
On 2 Aug, 19:29, Shashank Agarwal <shashank...@yahoo.com> 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/.
Shashank Agarwal 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
--
Phlip
Thanks for your replies. I'll look into SCP and try using SFTP. 
--
Posted via http://www.ruby-forum.com/.
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 Sun, Aug 03, 2008 at 03:23:53AM +0900, Phlip wrote:
Shashank Agarwal 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
--
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
Yasir Arafat on religious wars: "You're basically killing each other to
see who's got the better imaginary friend."
Shashank Agarwal 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.
--
Posted via http://www.ruby-forum.com/\.
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.
On Mon, Aug 04, 2008 at 09:27:11AM +0900, James Dinkel wrote:
Shashank Agarwal 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.
--
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
Zat was zen, dis is tao. http://tao.apotheon.org
Chad Perrin 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.
--
Posted via http://www.ruby-forum.com/\.