Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A shell script to add FTP users in 10.3 UNIX
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:
#!/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.
    •    
  • Currently 2.50 / 5
  You rated: 3 / 5 (4 votes cast)
 
[15,956 views]  

A shell script to add FTP users in 10.3 | 2 comments | Create New Account
Click here to return to the 'A shell script to add FTP users in 10.3' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A shell script to add FTP users in 10.3
Authored by: jpkunst on Mar 13, '04 02:04:13PM

I use PureFTPd, which has a nice Cocoa frontend ( PureFTPd Manager) as FTP daemon on Panther. PureFTPd has its own database of internal users so that you only need one FTP user at the system level. Very convenient.

JP



[ Reply to This | # ]
A shell script to add FTP users in 10.3
Authored by: juanfc on Mar 16, '04 05:39:47AM

PureFTP is all you need to manage FTP accounts completely. It has near all the features Rumpus has but instead of a strange Classic application the Rumpus is, PureFTP is pretty well integrated with the MacOSX UNIX operating system and with a Cocoa complete and simple user interface. And is free!!

Also compare the (use 'top') CPU use of both Rumpus and PureFTP !


---
---
juan



[ Reply to This | # ]