1

From what I see latest Ruby that supported FTPS was 1.8. I found some gems that can connect to FTPS, but they were no updated in several years. Did anyone had to do this recently? What gem did you use?

Andrew Bezzub
  • 15,744
  • 7
  • 51
  • 73
  • 1
    _For future references:_ As off **ruby-2.4.0** `Net::FTP` supports FTPS connections natively. Both FTP over SSL and FTP over TLS are supported. – UrsaDK Mar 27 '18 at 14:08

2 Answers2

1

You can simply use net/ftp standard library.

ftp = Net::FTP.new('cdimage.debian.org')
ftp.login
ftp.list

Or login to protected ftp:

ftp.login('username', 'password')
Babar Al-Amin
  • 3,939
  • 1
  • 16
  • 20
-1

And for FTPS you can use net/sftp https://github.com/net-ssh/net-sftp

example of code :

require 'net/sftp'

Net::SFTP.start('host', 'username', :password => 'password') do |sftp|
  # upload a file or directory to the remote host
  sftp.upload!("/path/to/local", "/path/to/remote")

  # download a file or directory from the remote host
  sftp.download!("/path/to/remote", "/path/to/local")

  # grab data off the remote host directly to a buffer
  data = sftp.download!("/path/to/remote")

  # open and write to a pseudo-IO for a remote file
  sftp.file.open("/path/to/remote", "w") do |f|
    f.puts "Hello, world!\n"
  end

  # open and read from a pseudo-IO for a remote file
  sftp.file.open("/path/to/remote", "r") do |f|
    puts f.gets
  end

  # create a directory
  sftp.mkdir! "/path/to/directory"

  # list the entries in a directory
  sftp.dir.foreach("/path/to/directory") do |entry|
    puts entry.longname
  end
end
  • 3
    SFTP (SSH File Transfer Protocol) is not the same as FTPS (FTP over SSL). `Net::SFTP` will not help with connecting to an *ftps* server. – UrsaDK Mar 15 '18 at 18:44