Setting Up ProFTPd + TLS On Ubuntu 11.04 (Natty Narwhal)

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2011-09-25 19:37. :: Ubuntu | FTP | Security

Setting Up ProFTPd + TLS On Ubuntu 11.04 (Natty Narwhal)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter
Last edited 07/05/2011

FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure. This article explains how to set up ProFTPd with TLS on an Ubuntu 11.04 server.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing

sudo su

 

2 Installing ProFTPd And OpenSSL

OpenSSL is needed by TLS; to install ProFTPd and OpenSSL, we simply run:

apt-get install proftpd openssl

You will be asked a question:

Run proftpd: <-- standalone

For security reasons you can add the following lines to /etc/proftpd/proftpd.conf (thanks to Reinaldo Carvalho; more information can be found here: http://proftpd.org/localsite/Userguide/linked/userguide.html):

vi /etc/proftpd/proftpd.conf

[...]
DefaultRoot ~
ServerIdent on "FTP Server ready."
[...]

 

3 Creating The SSL Certificate For TLS

In order to use TLS, we must create an SSL certificate. I create it in /etc/proftpd/ssl, therefore I create that directory first:

mkdir /etc/proftpd/ssl

Afterwards, we can generate the SSL certificate as follows:

openssl req -new -x509 -days 365 -nodes -out /etc/proftpd/ssl/proftpd.cert.pem -keyout /etc/proftpd/ssl/proftpd.key.pem

Country Name (2 letter code) [AU]: <-- Enter your Country Name (e.g., "DE").
State or Province Name (full name) [Some-State]:
<-- Enter your State or Province Name.
Locality Name (eg, city) []:
<-- Enter your City.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
<-- Enter your Organization Name (e.g., the name of your company).
Organizational Unit Name (eg, section) []:
<-- Enter your Organizational Unit Name (e.g. "IT Department").
Common Name (eg, YOUR name) []:
<-- Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com").
Email Address []:
<-- Enter your Email Address.

 

4 Enabling TLS In ProFTPd

In order to enable TLS in ProFTPd, open /etc/proftpd/proftpd.conf...

vi /etc/proftpd/proftpd.conf

... and uncomment the Include /etc/proftpd/tls.conf line:

[...]
#
# This is used for FTPS connections
#
Include /etc/proftpd/tls.conf
[...]

Then open /etc/proftpd/tls.conf and make it look as follows:

vi /etc/proftpd/tls.conf

<IfModule mod_tls.c>
TLSEngine                  on
TLSLog                     /var/log/proftpd/tls.log
TLSProtocol                SSLv23
TLSOptions                 NoCertRequest AllowClientRenegotiations
TLSRSACertificateFile      /etc/proftpd/ssl/proftpd.cert.pem
TLSRSACertificateKeyFile   /etc/proftpd/ssl/proftpd.key.pem
TLSVerifyClient            off
TLSRequired                on
</IfModule>

If you use TLSRequired on, then only TLS connections are allowed (this locks out any users with old FTP clients that don't have TLS support); by commenting out that line or using TLSRequired off both TLS and non-TLS connections are allowed, depending on what the FTP client supports.

Restart ProFTPd afterwards:

/etc/init.d/proftpd restart

That's it. You can now try to connect using your FTP client; however, you should configure your FTP client to use TLS (this is a must if you use TLSRequired on) - see the next chapter how to do this with FileZilla.

If you're having problems with TLS, you can take a look at the TLS log file /var/log/proftpd/tls.log.

 

5 Configuring FileZilla For TLS

In order to use FTP with TLS, you need an FTP client that supports TLS, such as FileZilla.

In FileZilla, open the Server Manager:

Select the server that uses ProFTPd with TLS; in the Server Type drop-down menu, select FTPES instead of normal FTP:

Now you can connect to the server. If you do this for the first time, you must accept the server's new SSL certificate:

If everything goes well, you should now be logged in on the server:

 

6 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by casthos (not registered) on Thu, 2012-05-31 12:00.
Don't forget to enable mod_tls.c in /etc/proftpd/modules.conf, (uncomment the ligne). Othewise it will not work and if you try to run protftpd -td5, to check the configuration, you can see  <IfModule>: skipping 'mod_tls.c' section at line... .
Submitted by Bogdan (not registered) on Fri, 2011-12-16 09:34.

If your server has a private address (ex. 192.168.1.150) you must edit two options in /etc/proftpd/proftpd.conf and then open a range of ports on your router to be forwarded to 192.168.1.150

In my filezilla logs i have :

Status:    Server sent passive reply with unroutable address. Using server address instead.
Command:    MLSD
Error:    GnuTLS error -53: Error in the push function.

 

To resolve this edit  /etc/proftpd/proftpd.conf and modify the lines like that :

 

PassivePorts                  52500 52510

 

MasqueradeAddress               89.33.34.35

 

Passive ports it's a range of ports forwarded to the internal IP : 52500-52510

MasqueradeAddress is your public IP (in my case 89.33.34.35)

Then open a range of ports on your router (52500-52510) , and forward them to your private IP (192.168.1.150) in my case.

Submitted by Mark (not registered) on Sat, 2011-10-22 15:56.
Thank you. It was very helpful.
Submitted by christophevr (registered user) on Sat, 2011-10-08 10:48.

Hello There is just A little add . A kind of run time error caused failure of start at boot time from proftpd in natty. When :

Pc is fast,Network manager is used and :

Using masquerading address and Tls behind Nat router . (masquerading is needed as router can't interpret the ftp commands when using tls. The client however needs the correct link. To the passieve ftp ports used opened when up or downloading files). 

To solve this do : sudo update-rc.d -f proftpd remove. And add an upstart script in

/etc/init  called proftpd.conf which looks like

# Proftpd
#Use this instead of standard(old) rc.d When using network manager
#and dns masquer address Otherwise proftp start may fail due to no dns lookup avbl yet
#during boottime. With this proftpd will only start when network device is up
#


description    "proftpd"

start on (local-filesystems and net-device-up IFACE!=lo)          
stop on runlevel [016]

expect fork
respawn

pre-start script
    mkdir -p /var/run/proftpd

end script

script

exec proftpd -c /etc/proftpd/proftpd.conf

end script

 On an older pc It's start ok with the rc.d scripts But with a fast pc and using network manager with ubuntu natty. The failure during boot time of proftpd occurs with message -fatal unable to resolve masquerading xxxx.xxx.cx

 

Submitted by Liquid (not registered) on Fri, 2011-09-30 09:31.

Function only with older release of FileZilla 3.0.11.1 - http://filehippo.com/download_filezilla/4377/

 What about to define CipherSuite acording to bad news about SSL/TLS and AES?

TLSProtocol                     SSLv3
TLSCipherSuite                  !aNULL:!eNULL:!EXPORT:!DSS:!DES:!ADH:!SSLv2:RC4-SHA:RC4-MD5