# Copy remote a file

**URL:** <https://www.ruby-forum.com/t/copy-remote-a-file/149823>\
**Category:** Ruby\
**Created:** [September 30, 2008, 10:16am UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823 "2008-09-30T10:16:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [September 30, 2008, 10:16am UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823/1 "2008-09-30T10:16:51Z")

</div>

How can i copy with ruby a file from my computer to another computer  
from lan? I have the administrator password of that computer.

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [September 30, 2008, 10:40am UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823/2 "2008-09-30T10:40:24Z")

</div>

Bu Mihai wrote:

> How can i copy with ruby a file from my computer to another computer  
> from lan? I have the administrator password of that computer.

If the way you login to the other computer is with ssh, then I’d suggest  
using Net::SFTP (available as a gem)

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [September 30, 2008, 10:52am UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823/3 "2008-09-30T10:52:47Z")

</div>

On Tue, Sep 30, 2008 at 9:15 AM, Bu Mihai [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> How can i copy with ruby a file from my computer to another computer  
> from lan? I have the administrator password of that computer.

If it’s UNIX/Linux, use scp . If it’s Windows, expect you can use file  
shares  
(or just stick it on a webserver and pull it down with a browser).

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [September 30, 2008, 6:35pm UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823/4 "2008-09-30T18:35:22Z")

</div>

On Tue, Sep 30, 2008 at 4:28 AM, Bu Mihai [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> require ‘net/ssh’  
> require ‘net/sftp’  
> session = Net::SSH.start(“machine1”,“administrator”,“baubau”)
> 
> I have this error:  
> c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh.rb:151:in  
> `start': undefined method `keys’ for “baubau”:String (NoMethodError)  
> from connect.rb:10
> 
> The machine1 is up and the password is a valid one.

According to the docs for SSH (and also SFTP), the third parameter  
should be a Hash…

session = Net::SSH.start(“machine1”, “administrator”, :password =\>  
“baubau”)

…or for SFTP…

session = Net::SFTP.start(“machine1”, “administrator”, :password =\>  
“baubau”)

Try it outside of ruby first (in unix shell)…

> sftp administrator@machine1

Todd

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [September 30, 2008, 11:29am UTC](https://www.ruby-forum.com/t/copy-remote-a-file/149823/5 "2008-09-30T11:29:50Z")

</div>

Brian C. wrote:

> Bu Mihai wrote:
> 
> > How can i copy with ruby a file from my computer to another computer  
> > from lan? I have the administrator password of that computer.
> 
> If the way you login to the other computer is with ssh, then I’d suggest  
> using Net::SFTP (available as a gem)

i have this problem with net::sftp:  
code:  
require ‘net/ssh’  
require ‘net/sftp’  
session = Net::SSH.start(“machine1”,“administrator”,“baubau”)

I have this error:  
c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh.rb:151:in  
`start': undefined method`keys’ for “baubau”:String (NoMethodError)  
from connect.rb:10

The machine1 is up and the password is a valid one.
