Questions tagged [net-sftp]

Net/SFTP is a ruby library for interfacing with native SFTP connections. It is related to Net/SSH, Net/SCP and others.

Net/SFTP is a ruby library for interfacing with native SFTP connections. It is related to Net/SSH, Net/SCP and others. Project Info

102 questions
10
votes
1 answer

RSpec: Stubbing SFTP

I'm attempting to stub out Net::SFTP from an object. Here's the model: class BatchTask require 'net/sftp' def get_file_stream(host, username, password, path_to_dir, filename) raise ArgumentError if host.nil? or username.nil? or…
Sly
  • 743
  • 13
  • 38
8
votes
1 answer

Public/Private key authentication for Ruby Net::SFTP

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 =…
Blair Anderson
  • 19,463
  • 8
  • 77
  • 114
7
votes
3 answers

Transfer large file via SFTP in PHP

I have a large file (200 MB upwards). I need to transfer it via PHP cron job. Using Phpseclib gives the following error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4133 bytes) in…
Abhishek
  • 1,459
  • 3
  • 19
  • 35
7
votes
1 answer

Using phpseclib to close a Net_SFTP connection

I have a program written in PHP that distributes files to various FTP sites. Recently, I added SFTP support to it using phpseclib. It's very easy to use to log in and upload the files. However, there doesn't seem to be an explicit function to close…
David Spencer
  • 77
  • 1
  • 9
7
votes
3 answers

Net::SFTP connection not closing

I have a Ruby on Rails (Rails 3.2.14 and ruby 1.9.3) application that uploads 2 files to a remote SFTP server. The SFTP code is: require 'net/sftp' Rails.logger.info("Creating SFTP connection") uri = URI.parse('sftp://'+…
adnann
  • 197
  • 3
  • 12
6
votes
1 answer

How can I create a file/directory tree from Net-SFTP results?

I'm trying to create a tree of files and directories using the net-sftp library. I can get a recursive listing of files by using the .glob method and can determine if one of the results is a directory by using the .opendir method. I've been able…
Jamie Little
  • 179
  • 1
  • 11
5
votes
1 answer

"permission denied" when uploading a file with Rails SFTP

I am working on an integration that requires my Rails 4 app to push a CSV to an SFTP server daily. The app will eventually live on Heroku. I am using the 'net-sftp' gem. Moving the file via FTP client (FileZilla) works. Here's the very simple…
Taylor Boren
  • 53
  • 1
  • 4
5
votes
3 answers

ruby net-sftp read file line by line

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…
Luigi
  • 5,443
  • 15
  • 54
  • 108
4
votes
1 answer

Ruby Net-SFTP Unresponsive

I'm trying to upload a file to a SFTP site using Net::SFTP. The problem is the Ruby process never returns. It's frozen, stuck, never-ending... I have to Ctrl-C to make it stop. I can connect to the ftp server in the command line using sftp. I've…
user498023
  • 548
  • 1
  • 4
  • 9
4
votes
1 answer

Undefined method 'e=' for #

I'm trying to download file from Heroku's SFTP To Go using net/sftp gem but I always get undefined method `e=' for #. Been searching online but can't find any related solutions. Here is my code: task employer_email_import: :environment do require…
RSync
  • 121
  • 11
4
votes
2 answers

`dispatch_request': no such request during Net::SFTP.upload

I'm using Net::SFTP to upload a file to a server. Here is the code: uri = URI.parse('sftp://host.org') io = StringIO.new(csv_string) timeout 120 do Net::SFTP.start(uri.host,ENV['SFTP_USER'],:password=>ENV['SFTP_PASS'],:port=>22) do |sftp| …
ChaosFreak
  • 574
  • 1
  • 6
  • 18
4
votes
5 answers

Encoding::UndefinedConversionError: "\xA8" from ASCII-8BIT to UTF-8 (SFTP)

Using the Net-SFTP gem, Ruby 2 and Rails 4 I wrote code that was working in pure ruby, but copied my code over to rails and now I get: Encoding::UndefinedConversionError: "\xA8" from ASCII-8BIT to UTF-8 What can I change in my code to get this…
user2012677
  • 5,465
  • 6
  • 51
  • 113
4
votes
3 answers

How can I identify if an item is a file or a directory using Net::SFTP?

How to identify whether the item of a directory is a file or a directory using Net::SFTP or ruby code?
Aditya
  • 425
  • 3
  • 8
  • 22
4
votes
2 answers

Net::SFTP sort directory files?

I'm currently doing the following to get a list of all the files in a directory: Net::SFTP.start('host', 'username', :password => 'password') do |sftp| sftp.dir.foreach("/path") do |entry| puts entry.name end end But that lists the files…
Shpigford
  • 24,748
  • 58
  • 163
  • 252
4
votes
1 answer

IOError: closed stream in Ruby SFTP

The following code tries to list the entries of a remote directory via SFTP and Net::SFTP, but it causes an "closed stream" IOError if the directory contains a large number of files (~ 6000 files): require 'net/ssh' require…
0x4a6f4672
  • 27,297
  • 17
  • 103
  • 140
1
2 3 4 5 6 7