Ruby on Rails

FTPS (TLS/SSL) In Ruby

FTPS is an extension to the commonly used FTP that adds support for the Transport Layer Security (TLS) and the Secure Sockets Layer (SSL) cryptographic protocols.

While FTPS using clients like FileZilla, we generally prefix our host with ‘ftpes://’:
ftpes://ftp.example.com

Net::SSH is the most popular ruby library for ssh and ftp purpose. It however is not so helpful when it comes to FTPS. We will use Net::FTPFXP RubyGem instead.

Installing Net::FTPFXP is simple. Run:
gem install ftpfxp

Now to establish the connection, do the following:
require 'net/ftptls'
ftp = Net::FTPTLS.new()
ftp.passive = true
ftp.connect('host.com', port_number)
ftp.login('Username', 'Password')
ftp.list
ftp.close

Port number by default is 21.

Advertisements
Standard

One thought on “FTPS (TLS/SSL) In Ruby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s