net-sftp

Public/Private key authentication for Ruby Net::SFTP

故事扮演 提交于 2019-12-13 15:22:22
问题 I am having trouble finding documentation for specifying a key for SFTP authentication. Would like to have something like: export SOME_PRIVATE_KEY="$(cat tmp/some-certs/privatekey.pem)" # then somewhere in the code private_key = OpenSSL::PKey::RSA.new(ENV['SOME_PRIVATE_KEY']) Net::SFTP.start(ftp_host, user, key: private_key) do |sftp| sftp.dir.entries('/path/to/folder').each do |remote_file| # ... end end 回答1: Net::SFTP.start passes its options hash directly to Net::SSH.start , so we should

ruby net-sftp read file line by line

假如想象 提交于 2019-12-10 17:11:24
问题 I am using ruby 2.0.0 and rails 4.0.0. I have something similar to this: require 'net/sftp' sftp = Net::SFTP.start('ftp.app.com','username', :password => 'password') sftp.file.open("/path/to/remote/file.csv", "r") do |f| puts f.gets end This opens the file on the FTP site, but it only puts the first line of the csv file. I need to read this file row by row, preferably ignoring the header. How can I read the file row by row, without downloading the file locally? 回答1: I solved this by doing

Files not uploading to remote server with Net_SFTP

久未见 提交于 2019-12-02 14:22:56
问题 I have the following class for uploading files in a directory, however, the first directory that should be created is getting set up as 'File' rather then a 'File Folder'. Because of that, the items that should be uploaded are not uploading properly. I'm not sure if I am missing a step or not or if I set this up incorrectly. include 'Net/SFTP.php'; class SFTPConnection { private $sftp; public function __construct($host, $username, $password) { $this->sftp = new Net_SFTP($host); if (!$this-