Secure ProFTPD

Hi,

I see the ProFTPD setup on Iworx is:

 -     Module: mod_core.c
 -     Module: mod_xfer.c
 -     Module: mod_auth_unix.c
 -     Module: mod_auth_file.c
 -     Module: mod_auth.c
 -     Module: mod_ls.c
 -     Module: mod_log.c
 -     Module: mod_site.c
 -     Module: mod_auth_pam.c
 -     Module: mod_ratio.c
 -     Module: mod_readme.c
 -     Module: mod_sql.c
 -     Module: mod_sql_mysql.c
 -     Module: mod_cap/1.0

I want to add SSL to it because I feel like it makes sense as FTP passwords (and files) are passed in clear text. I would want both the passwords and files transfer to be secure when I need them to be without having to use the web based file managment in siteworx.

Is there any problem adding this manually before Iworx supports it following the following instructions: http://www.castaglia.org/proftpd/modules/mod_tls.html

I wanted to ask first as this is a production server and dont want to break anything.

Thanks in advance for your help

:smiley:

./configure

I assume all I need to do is:

./configure \
--with-modules=mod_sql:mod_sql_mysql:mod_tls \
--with-includes=/usr/include/mysql/:/usr/include/openssl/ \
--with-libraries=/usr/lib/mysql/

make;make install

Is there supposed to be library file I need to include for openssl?

I did a “find / -name ‘openssl’” and the only thing it came up with was:

/usr/bin/openssl
/usr/include/openssl (I have included this above)

Also, I had to do some extra things last time I manually upgraded ProFTPD on a recomendation from Sago (Thanks Sago-Dan). Will I still have to do the following steps to complete the configuration?

There’s a few things which you have to mod to get it to work in interworx.
The default configuration build of proftpd is pointing to another location (after the make install ) /usr/local/etc/proftpd.conf

If you remove that file with:
10. rm /usr/local/etc/proftpd.conf
then link it to the current one

  1. ln -s /etc/proftpd.conf /usr/local/etc/proftpd.conf

You should have the configuration part set.
You may also have to copy the files to the proper location because the rpm’ed version of proftpd is stored in /usr/sbin and not /usr/local

Just copy the files which were compiled to the /usr/sbin
12. cp proftpd /usr/sbin
13. cp ftp* /usr/sbin

Then proceed with starting the proftpd service

  1. service proftpd start

Sago-Dan :: http://sagonet.com/forums/viewtopic.php?t=373

Justin,

I’d try this instead as it’s a bit cleaner and you don’t have to do any special compiling outside of the RPM infrastructure.

If you’re on RH9, which I’m assumign you are just do:


rpmbuild --rebuild --with rht90 --with mod_tls http://updates.interworx.info/iworx/SRPMS/proftpd-1.2.10-100.iworx.src.rpm

When that’s done building you can simply


rpm -Uvh --force /usr/src/redhat/RPMS/i386/proftpd-1.2.10-100.iworx.rpm

The --force is needed since the same version (without tls) is already installed.

Regarding the proftpd.conf you DO NOT want to overwrite or other not use the proftpd.conf that comes with iworx. It has the DB connection strings in the conf file that are needed for proftpd to connect to the SQL auth backend. I’d just hand copy any TLS stuff that is needed to the /etc/proftpd.conf.

Chris

[SIZE=5][SEE POST #14 FOR UPDATED STEPS ][/SIZE]
http://interworx.info/forums/showpost.php?p=3464&postcount=14

Thanks for the info Chris.

I have followed your instructions and everything went perfect.
The RPM file name was a little different then the one you specified, but it wasn’t hard to figure out the correct one for my server. There was a ‘.i386’ after the iworx (proftpd-1.2.10-100.iworx.i386.rpm).

I ran the force and it it went okay:


[root@server1 i386]# rpm -Uvh --force /usr/src/redhat/RPMS/i386/proftpd-1.2.10-100.iworx.i386.rpm
Preparing...                ########################################### [100%]
   1:proftpd                warning: /etc/proftpd.conf created as /etc/proftpd.conf.rpmnew
########################################### [100%]
Starting proftpd: [  OK  ]

I tried connecting securely using SmartFTP (http://www.smartftp.com/support/kb/index.php/166) but it failed to connect.

Using Explicit:
220 FTP Server Ready
AUTH SSL
500 AUTH not understood

220 FTP Server Ready
AUTH TLS
500 AUTH not understood

Using Implicit:

Connected. Exchanging encryption keys...
SSL Error
The token supplied to the function is invalid
Connection closed.

Any ideas?

Thanks for the help! :smiley:

[SIZE=5][SEE POST #14 FOR UPDATED STEPS ][/SIZE]
http://interworx.info/forums/showpost.php?p=3464&postcount=14

I guess I thought the config file was magically going to add the module code and know where my SSL certificates are by itself.

After adding the following code (based on the sample below) it connected:

<IfModule mod_tls.c>
TLSEngine on
TLSLog /var/log/tls.log
TLSProtocol SSLv23 # this selects the latest crypt version

TLSOptions NoCertRequest # this is REALLY important for WinClients

# Are clients required to use FTP over TLS when talking to this server?
TLSRequired on

# Server's certificate
TLSRSACertificateFile /etc/openldap/ldapcert.pem
TLSRSACertificateKeyFile /etc/openldap/ldapkey.pem
TLSCACertificateFile /etc/openldap/demoCA/cacert.pem

# Authenticate clients that want to use FTP over TLS?
TLSVerifyClient off
</IfModule>

Thanks for you help, this should come in handy when trasnfer PHP scripts that I don’t want other people seeing!

Also, is there any benefit to running the SSL version on port 990 version both on port 21?

Sorry, I should have mentioned that there was “extra setup” to be done. But you got it :).

Regarding your 2nd question there’s no real benefit. Port 21 = un-secured FTP so I’d stick with it on 990 personally.

Chris

I’m using SmartFTP and there is two connection methods.

http://www.smartftp.com/support/kb/index.php/166

The Explicit connection works with Mod_TLS, but how would I go about making it work with Implicit?

Also, is there a way to make port 990 secure only? I added a virtual host to the proftpd config file and now it listens on 21 and 990, but conneting to either works with our with SSL.

Also, I’m trying to get DreamWeaver 2004 to connect via SSL and it doesn’t so I’m thinking it is using the implicit method that I can’t connect with when using SmartFTP.

Any ideas?
:confused:

From what I’ve read on the proftpd author’s site (http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-TLS.html) the current tls implementation doesn’t support the ‘implicit’ method (the doc was updated on 10/9 so I’m assuming it’s current).

I haven’t setup tls on a proftpd server yet so without trying it out I am probably a bad source. But if you want me to login to your box and play around with it I’d be happy to just to see it working :).

Chris

I have sent in a support ticket with the info.

EDIT:
I sent two tickets b/c the first one I had a typo in my email address.

Did you ever get a chance to check this out?

It works great using SmartFTP, but not when using dreamweaver

I haven’t Justin and I apologize. It’s been maddeningly busy over here getting the releases ready.

Chris

It’s pretty much the same as setting up SSL in the apache config file. I know you can now setup SSL with SiteWorx although I haven’t tried it because I already set a manual way of doing it on my server that is really easy. But if you haven’t set it up on Apache what I said probably didn’t help you too much.

There are 3 parts to setup SSL:

  1. The certificate, which I guess is just another term for public key. This is what the client uses to encrypt the first request to establish a secure connection. Everyone can encrypt with it, but only the person (hopefully just you) with the private key can decrypt it.

  2. The private key

  3. The certificate authority certificate. This is from whomever you buy your certificate from. I think it’s what the browsers look at to see if that is a trust certificate.

So to set this up in ProFTPD you have these lines:

Server’s Certificate

TLSRSACertificateFile /path/to/ssl/yourcertificate.crt
TLSRSACertificateKeyFile /path/to/ssl/yourprivatekey.key
TLSCACertificateFile /path/to/ssl/CAcertificate.crt

I’m not sure if you could just create a private key / certificate and use it as unsigned (no CAcertificate.crt). Maybe you should try using the SiteWorx SSL feature and then make the /path/to/ssl point to where those are stored.

Or you could just wait till the next update of Iworx ProFTPD because I guess there is a demand for it and they are right there to meet that demand (Good job guy’s, like to see you stay ahead of the curve :smiley: )
http://interworx.info/forums/showthread.php?p=3417

I just tried something that works and you won’t have to create your own key and certificate!

Also, the compile code is a little different now. This is if you are on Redhat 9.0 box. If you are on another box then you change out the rht90 for your OS.

Step1:

rpmbuild --rebuild --with rht90 --with mod_tls http://updates.interworx.info/iworx/SRPMS/proftpd-1.2.10-100.iworx.src.rpm

Step2:

rpm -Uvh --force /usr/src/redhat/RPMS/i386/proftpd-1.2.10-100.rht90.iworx.i386.rpm

Step3:
Edit the /etc/proftpd.conf file. Just add the following to the very bottom of the file (After ). Just copy and paste this in verbatim.

<IfModule mod_tls.c>
 TLSEngine on
 TLSLog /var/log/tls.log
 TLSProtocol SSLv3

 TLSOptions NoCertRequest

 # Server's Certificate
 TLSRSACertificateFile /home/interworx/etc/ssl/iworx.crt
 TLSRSACertificateKeyFile /home/interworx/etc/ssl/iworx.key

</IfModule>

Step4:

service proftpd restart

I just did this exact thing on my Red Hat 9 box since something got messed up when I rebooted about a week ago because I think Iworx change all the RPMs now for each linux OS.

Good luck and hopefully this should get you up and running with your SFTP server.

Did you mean proftpd.conf or proftpd.conf.rpmnew? I thought it would look at .conf and not the .rpmnew.

Do I add it AFTER the /GLOBAL?

Lastly, sadly, I have to ask - how do i choose to turn it on? I figured it would be on my default if i try to connect using TLS now. When I try to connect with TLS after following those steps, I still get:

[L] 220 FTP Server Ready
[L] AUTH TLS
[L] 500 AUTH not understood
[L] Failed SSL/TLS negotiation, disconnected
[L] Connection failed (Connection lost)

EDIT: Oh and:

[root@server etc]# proftpd -l
Compiled-in modules:
mod_core.c
mod_xfer.c
mod_auth_unix.c
mod_auth_file.c
mod_auth.c
mod_ls.c
mod_log.c
mod_site.c
mod_auth_pam.c
mod_ratio.c
mod_readme.c
mod_sql.c
mod_sql_mysql.c
mod_tls.c
mod_cap.c

proftpd.conf.rpmnew is the new config file the RPM creates so it doesn’t overwrite your orignal config file. So that is why you need to edit that one.

I added mine after the </GLOBAL>

I think you may have everything setup right on the server, but you need to configure your client application correctly.

I use SmartFTP and it works, but one thing I noticed is you have it as Auth_TLS. Set up your client to use the AUTH SSL and not TLS.

Let me know if that works!

Using FlashFXP:

Implicit SSL:
[L] Connected. Negotiating SSL session…
[L] SSL ERROR: unknown protocol
[L] Connection failed (Connection closed by client)

AUTH SSL:
[L] 220 FTP Server Ready
[L] AUTH SSL
[L] 500 AUTH not understood
[L] Failed SSL/TLS negotiation, disconnected
[L] Connection failed (Connection lost)

AUTH TLS:
[L] 220 FTP Server Ready
[L] AUTH TLS
[L] 500 AUTH not understood
[L] Failed SSL/TLS negotiation, disconnected
[L] Connection failed (Connection lost)

So no go =/ I have no trouble connecting with SSL with this app otherwise =/ I’m thinking I have to enable SSL on ProFTPD somewhere… somehow.


EDIT: I modified the proftpd.conf file instead, since i was sure that’s the one proftpd uses - and I got a somewhat different response. It looks like it’s TRYING now. The .conf.rpmnew file was just created so that it wouldn’t replace the .conf on us. It’s not the one ProFTPD looks at/for.

After adding the TLS code you pasted into proftpd.conf, i get:

Implicit SSL:
[L] Connected. Negotiating SSL session…
[L] SSL ERROR: unknown protocol
[L] Connection failed (Connection closed by client)

Auth SSL:
[L] AUTH SSL
[L] 234 AUTH SSL successful
[L] Connected. Negotiating SSL session…
[L] error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
[L] Connection failed (Connection closed by client)

Auth TLS:
[L] 234 AUTH TLS successful
[L] Connected. Negotiating TLSv1 session…
[L] error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
[L] Connection failed (Connection closed by client)

Sorry I forgot to mention it has to be “Explicit” and “Auth SSL” for it to work.

I would try that and if that doesn’t work maybe you forgot to restart ProFTPD after you updated the config file?

If you want to create a temp dummy ftp account on your server I can see if I can connect to it, just send me a PM.

[EDIT]
Actually thats not true, it HAS TO be “Explicit” but you can use Auth TLS as well as Auth SSL.

Sorry about the mis-info on the .rpmnew, I have recompilied this a couple times and got confused on which one was which.

I just double checked putting the Interworx Certifcate code in the real .conf file on my server and it still works so the new error you have is probably something with your FTP program. Try using SmartFTP (www.smartftp.com).

And make sure to use Explicit.

[EDIT]
I just installed FlashFXP trial and was able to connect to my server using both Auth_TLS and Auth_SSL. I did get a warning about the InterWorx Certificate being self-signed, but thats it.

Pfft - as if you have any reason to apologize to me for ANYTHING! =)
I can see how it would be confusing - I remember seeing the message after it compiled.

I used CuteFTP Pro 7 and tried Explicit and that didn’t work either. I’ll try SmartFTP. I’ll keep you posted.

Thanks again Justec!