When adding ftp users on my Panther system with the proftpd server, I had to go through some tasks: make a new user account in the System Preferences, change some values such as the home directory in NetInfo Manager, delete the home directory made (because I use one directory for all ftp users), and add an entry to the proftpd configuration file.
This was very annoying and time-consuming. Now I've written a simple script to save me lots of time. It's heavily based on a script to add users with niutil that exists already some years.
Read the rest of the hint for the script...
[robg adds: I haven't tested this one...]
file addftpuser.sh:
This was very annoying and time-consuming. Now I've written a simple script to save me lots of time. It's heavily based on a script to add users with niutil that exists already some years.
Read the rest of the hint for the script...
[robg adds: I haven't tested this one...]
file addftpuser.sh:
#!/bin/sh
# AddFtpUser 03/04/2004 koan
#
# Manipulates Netinfo and ftpd configuration to add ftp users from the commandline. Compatible with Panther and proftpd.
# Based on NetInfo SysAdmin Scripts For Mac OS X Server by Aaron Faby
ftpdconf="/sw/etc/proftpd.conf"
if [ $USER != "root" ]; then
echo "You must be root to execute this script."
exit
fi
echo -n "Username: "
read uname
# give the user no shell
shell="/usr/bin/false"
uiddef=`nidump passwd . | cut -d: -f3 | sort -n | tail -n 1`
uiddef=`echo $uiddef + 1 |bc`
uid=$uiddef
# group staff
gid=20
homedef=/Users/koan/Music
echo -n "Home [$homedef]: "
read home
if [ "$home" = "" ]; then
home=$homedef
fi
echo -n "Real name [Ftp User]: "
read irl
if [ "$irl" = "" ]; then
irl="Ftp User"
fi
echo -n "IP address [all]: "
read ip
if [ "$ip" = "" ]; then
ip="all"
fi
# ask password
passwd=`openssl passwd`
echo -n "Creating User..."
# Add User to NetInfo
# the trick to make it work in Panther:
# set password string from openssl in passwd,
# and set authentication_authority to ;basic;
niutil -create . /users/$uname
niutil -createprop . /users/$uname passwd $passwd
niutil -createprop . /users/$uname gid $gid
niutil -createprop . /users/$uname uid $uid
niutil -createprop . /users/$uname shell $shell
niutil -createprop . /users/$uname home $home
niutil -createprop . /users/$uname realname "$irl"
niutil -createprop . /users/$uname _shadow_passwd
niutil -createprop . /users/$uname authentication_authority ";basic;"
# now create entry in ftpd configuration file
cat addftpuser.conf | sed "s/FTPUSER/$uname/"| sed "s/IP/$ip/" >> $ftpdconf
echo "Done"
file addftpuser.conf:
<Anonymous ~FTPUSER>
User FTPUSER
Group staff
MaxClients 2 "Sorry, max. number of clients reached"
AnonRequirePassword on
<Limit LOGIN>
Order Allow,Deny
Deny from all
Allow from IP
</Limit>
</Anonymous>
You can adapt it to your ftp configuration by changing the user entry in addftpuser.conf. FTPUSER and IP get substituted by the user name and ip address you enter in the script.
•
[16,108 views]

