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 users directory:

cd /usr/local/directadmin/data/users

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

#!/bin/sh

PF=/etc/proftpd.passwd

for u in `ls`; do
{
   if [ ! -d $u ]; then
     continue;
   fi

   SHADOW=/home/$u/.shadow
   if [ ! -e $SHADOW ]; then
     continue;
   fi

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

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

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

};
done;

Save/exit, then chmod the script to 755.

chmod 755 fix_ftp.sh

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

./fix_ftp.sh

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:

./fix_ftp.sh >> /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 ftp@domain.com accounts).

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

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

 
ftp/re-add.txt · Last modified: 2010/02/22 04:28 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki