Reputation: 590
So far as I can tell I need to use both Net::SCP and Net::SSH if I want to copy a file to a remote host and then manipulate it from the command line.
It would be nice to set up one SSH session, do the copy and then use the same connection to unpack the file and install them.
Am I missing something?
Upvotes: 3
Views: 2259
Reputation: 1772
Net::SCP allows you to easily grab a Net::SCP reference from an existing Net::SSH session:
require "net/ssh"
require "net/scp"
Net::SSH.start("remote.host", "username", :password => "passwd") do |ssh|
ssh.scp.upload("/local/path", "/remote/path")
ssh.exec("...insert commands...")
end
Read more here: http://net-ssh.github.io/net-scp/classes/Net/SCP.html
Upvotes: 7
Reputation: 935
Have you considered Net::SFTP? Along with that and Tempfile, I am currently using it in a project to copy from local to remote. You can also do simple file modifications. If you were so inclined, you could use Stream.IO to edit the file even more.
https://github.com/net-ssh/net-sftp
http://net-ssh.github.io/net-sftp/
Upvotes: 2