Skip to content

Instantly share code, notes, and snippets.

@huskercane
Last active October 20, 2021 00:13
Show Gist options
  • Save huskercane/b4a5a0fe5ab383e1363e to your computer and use it in GitHub Desktop.
Save huskercane/b4a5a0fe5ab383e1363e to your computer and use it in GitHub Desktop.
Use ruby net-sftp or net-ssh with private key authentication
require 'net/sftp'
SERVER = "127.0.0.0"
KEY_FILE = "/tmp/id_rsa"
Net::SFTP.start(SERVER, 'huskercane', :keys=>[KEY_FILE]) do |sftp|
sftp.mkdir! "/tmp/something"
#thats right needs full file name to copy
sftp.upload!("/tmp/something/something.txt", "/tmp/something/something.txt")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment