我正在尝试从一个 unix 盒子下载一个文件到内存缓冲区,然后将该文件上传到另一个 unix 盒子,但是当我尝试下载该文件时,它会要求我输入密码,即使我输入密码也会失败我已经尝试过:
data = Net::SCP.download!("remote.host.com", "username", "/remote/path", :password => password)
和
data = Net::SCP::download!("remote.host.com", "username", "/remote/path", :password => password)
但我得到:
Active Directory Password:
然后当我输入密码时:
Net::SCP::Error: SCP did not finish successfully (1)
ruby 1.8.7 (2010-12-23 补丁级别 330) [i386-mingw32]
网络SCP(1.0.4)
最佳答案
尝试像这样使用它:
require 'net/scp'
data = nil
Net::SCP.start("remote.host.com", "username", :password => "password") do |scp|
data = scp.download!("/remote/path")
end
puts data
编辑:我只在 ruby ruby-1.9.3 上尝试过这个,抱歉
关于Ruby Net::SCP 下载要求输入密码然后失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16319094/