If you’re unlucky enough to have to connect to an FTPS server (SFTP ends up being much easier), the Double Bag FTPS gem makes things much easier.
A few finer points to note:
- “verify_mode: OpenSSL::SSL::VERIFY_NONE” makes your life easier in development mode – not to mention some FTPS sites won’t even have one
- Most servers don’t like active mode, so explicitly use passive mode. Your connection ends up hanging without it.
So usage is:
DoubleBagFTPS.open(host, user, password, nil, DoubleBagFTPS::EXPLICIT, verify_mode: OpenSSL::SSL::VERIFY_NONE) do |ftps| ftps.passive = true ftps.put("myfile.txt", filename) end
August 4, 2013 at 1:51 pm
thank you for this!
just started using this gem and was getting the following error when trying to upload a file:
C:/Ruby193/lib/ruby/1.9.1/net/ftp.rb:300:in `getresp’: 501 Server cannot accept argument. (Net::FTPPermError)
setting the mode to passive did the trick!
December 7, 2015 at 10:09 am
Same for me – I needed to set it to passive. Life saver!