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


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Ftp

How to re-add all system ftp accounts to your /etc/proftpd.passwd fileLast Modified: Oct 28, 2014, 11:10 pm
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 fix_ftp.sh (use your favorite editor):

nano fix_ftp.sh

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

#!/bin/sh

PF=/etc/proftpd.passwd

cd /usr/local/directadmin/data/users
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:

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


That's it, then just test out the ftp accounts.
 
Related Helpfiles
How ftp accounts for default domains on owned IP's work

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST