HOWTO: Change home directory for a virtual FTP user on a server running pure-ftpd

I run CPanel on my web server and I recently needed to add an FTP account for one of the domains I am hosting. This is easy enough using the FTP Accounts option from the domain's CPanel page. However, I needed to set the home directory for the FTP account to be outside the root web directory (/home/username/public_html). This is not possible from the CPanel interface, most likely because it's a security risk. I checked my server and it shows that I'm running pure-ftpd, so I have no idea why I needed to use the proftpd directory. Heres how I did it:


[email protected]:~# cd /etc/proftpd
[email protected]:~# ls
./ savememo username2 username3
../ username4 username5 username6
[email protected]:~# vi savememo


savememo:RiIR2pPqeBWSM:32023:32024::/home/savememo:/bin/ftpsh
ftp:Ad3Dg04yDsk2dF:14:50:FTP User:/home/savememo/public_ftp:/sbin/nologin
savememo_logs:RiIR2pPqeBWSM:32023:32024:savememo:/usr/local/apache/domlogs:/bin/ftpsh

As you can see, /etc/proftpd contains a file for each of the accounts on your server. Edit the file for the domain in question, in this case savememo.com, and locate the line for the FTP account for which you wish to change the home directory. If I wanted to change the savememo FTP account's home directory to /home/savememo/myfiles, the new file would look like this:


savememo:RiIR2pPqeBWSM:32023:32024::/home/savememo/myfiles:/bin/ftpsh

After editing the file using your favorite console editor, in my case it's vi, save the file and then restart your pure-ftpd service (I'm not sure if this is required).

[email protected]:~# /etc/init.d/pure-ftpd restart
Stopping pure-config.pl:
Stopping pure-authd:
Starting pure-config.pl: [ OK ]
Starting pure-authd:

And that should do it. Now if you go into the FTP Accounts section of the CPanel for the domain you're working with, you should see the new home directory for that FTP user.

Write a Comment

Comment

  1. As Sitha would say…. HUH?

    Never mind I got it now, just had to read it 2 times.

    With CuteFTP and with using Pair hosting, I was able to go into the root directory and into other peoples accounts, I just could not upload or delete files, but I could browse all I wanted to. Wonder if that still works…..?

  2. Yea, that’s not good. That tells me Pair is a baaad web host who doesn’t pay attention to basic security. Its a simple “chown user:user command that needs to be run whenever a new account is created.

    My situation was unique because I needed to set the home directory for the FTP user to something below the root web directory, which CPanel prevents you from doing because it would be a huge security risk. The solution, which required root access to the server, is simple as long as you know where and what to edit. 🙂