我想在建立ssh连接后将远程位置文件的内容复制到某个本地文件。
begin
ssh = Net::SSH.start("localhost", "user")
logger.info "conn successful!"
results = conn.exec!('ruby somefile "#{arguments}"')
#code to copy the contents of a.txt in remote location to local file
#IO.copy_stream (localfile, remotefile)
rescue
logger.info "error - cannot connect to host"
end
我尝试使用IO.copy_stream,但这不起作用。我该怎么做?
答案 0 :(得分:0)
使用Net::SCP.download!("remote.host.com", "username",
"/remote/path", "/local/path",
:password => password)
(需要Net :: SSH)传输文件:
{{1}}