Last active
October 20, 2021 00:13
-
-
Save huskercane/b4a5a0fe5ab383e1363e to your computer and use it in GitHub Desktop.
Use ruby net-sftp or net-ssh with private key authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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