如何使用Ruby调用使用SSH和SCP传输文件? [英] How do I transfer files using SSH and SCP using Ruby calls?

查看:290
本文介绍了如何使用Ruby调用使用SSH和SCP传输文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在目录 usr / share / ruby​​.rb 中有一个文件。我想通过使用Ruby调用使用SSH和SCP将该文件传输到基于IP的远程设备。任何人都可以帮助我?

I have a file in the directory usr/share/ruby.rb. I want to transfer that file to IP-based remote devices using SSH and SCP using Ruby calls. Can anyone help me?

推荐答案

例子:

example:

require 'net/scp'

    host = '10.10.10.10'
    login = 'foo'
    password = 'bar'

    Net::SCP.start(host, login, :password => password) do |scp|
      puts 'SCP Started!'
      scp.download('/usr/share/ruby.rb', '.')
    end

还有一个 scp.upload

这篇关于如何使用Ruby调用使用SSH和SCP传输文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆