Creating Users for Proftpd Server in PHP


I read on the site that it was possible to add users to an FTP server using the ftp_site command.  However, I have found out that the proftpd FTP server uses a different set of SITE commands and none of them appear to include adding users.  The SITE commands for proftpd seem to concentrate on file and directory tasks rather than user based tasks.

I am using a form on my site where people can add a username and password to create a FTP login for my proftp server.  Now I realise that proftp is not going to simply allow the SITE ADDUSER command I am a bit stuck (well, very stuck).

How can I use a php/html form to add a user on a proftpd server?  This is the last hurdle that I now have with my new website and its something I must solve.

I would really really appreicate any help with this one.
Who is Participating?
administradoresConnect With a Mentor Commented:

I'd use method 2 using a database to store the ftp user & password then after the ftp account is validated by an admin or mod i'd use a php script or perl or whatever to edit etc/passwd where proftpd search for users. You can also create a php scripts with curl to create it from the CP.

You can also ask to your hosting how mutch would cost to install proftpd-mysql
ParadyneDesignsAuthor Commented:
My current thinking is that there is only two ways to solve this problem.

1.  Ask my server technical support to install proftpd-mysql so that I can write the data direct to a database table.  I have looked at this RPM and its not something I want to try and install myself as I need to remove the old RPM before starting and I am not a server person.

2.  Keep the system as is and put a 24 hour delay on the FTP account creation.  When my users request the FTP upload facility, they enter their details and that is saved to a database and on the screen they are prompted with "your FTP account needs authorisation and should be active within 24 hours".  Then I can create the account manually and send a confirmation email to them letting them know they can now use the FTP system.

Obviously, Option 1 is the way I really want to go but there is a cost involved with my server techs doing this and I have already spent thousands on this project.  Option 2 is less effective and has a delay for my users but is a feasilble workaround until I find something better.

If there are more options then I am very open to hearing them.  I know that my current FTP system stores a file in the etc/proftpd directory which holds the user info, but I cannot find a way to access that file via my php script to be able to update it automatically.

Maybe there is another FTP package that supports virtual hosting and is easier to install than the proftpd-mysql solution which supports the SITE ADDUSER command.  Preferably an RPM that can be easily installed via putty.

Also you can use php to connect via ssh and create the user from the shell.
ParadyneDesignsAuthor Commented:
I looked at the ssh route but there does not seem to be a command for proftpd in shell to create users!  I do think that route 2 is going to be the way I have to do it which is probably the safest also as I can check user activity before creating and allowing the ftp.

I'll look into the curl method and get back to you.
ParadyneDesignsAuthor Commented:
I decided to go with a manual update of the FTP accounts.  In hindsight, this is actually a safer system than having it created automatically as I have set it up so that I generate the passwords and also I can check the user records before allowing access.

I created a complete FTP admin system which is working well, so I am happy.

For the record:-  My server suppliers came back to me with a quote of $150 for the proftpd-mysql install but advised that it would have implications on how my Cpanel worked.  I agreed with them that it is probably a bad idea to upgrade as Cpanel might overwrite the RPM in an update.  My server suppliers are "The Planet" who operate one of the largest server setups in the world and who have been the most reliable I have ever used.  In the past 450 days my server has been down for 2 hours (due to a lose cable).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.