Add to Favourites Add to Favourites    Print this Article Print this Article

How to re-add all system ftp accounts to your /etc/proftpd.passwd file

If for whatever reason, you're missing all or some of your system ftp accounts in your /etc/proftpd.passwd file, you can do the following to ensure they're all present.

First change to the root directory:

cd /root

Then create a file called (use your favorite editor):


Inside this new file in your users directory, insert the following code:



cd /usr/local/directadmin/data/users
for u in `ls`; do
          if [ ! -d $u ]; then

          if [ ! -e $SHADOW ]; then

          #make sure it doesn't already exist
          COUNT=`grep -c -e "^${u}:" $PF`
          if [ "$COUNT" -ne 0 ]; then

          UUID=`id -u $u`
          UGID=`id -g $u`

          echo "${u}:`cat /home/$u/.shadow`:${UUID}:${UGID}:system:/home/${u}:/bin/false";


Save/exit, then chmod the script to 755.

chmod 755

Test it out first (it won't make any changes to your file like this):


make sure it's dumping out the information that goes into the proftpd.passwd file.
Once satisfied that it's the data you want, pipe it to the tail end of the file:

./ >> /etc/proftpd.passwd

making sure to use 2 > characters (>>)  and not just 1, as using just 1 would delete whatever was previously there (which is a bad thing if there are any accounts).

Make sure /etc/proftpd.passwd is chowned to root:ftp as well:

chown root:ftp /etc/proftpd.passwd
chmod 640 /etc/proftpd.passwd

That's it, then just test out the ftp accounts.

Was this answer helpful?

Also Read