Adding a user using php
Posted on 2003-03-18
I need to be able to add users on my system through php scripts but I'm having some problems. Currently, my web sign up page writes the commands to a file, and then a cron job executes this file every few hours and clears it.
I.E Whenever someone signs up, the php page will append the follwing 2 lines to a file:
/usr/bin/ssh my.user.server.com -l root /usr/sbin/useradd -s /bin/false -d /var/username username
/usr/bin/ssh my.user.server.com -l root /bin/echo "password" | /usr/bin/ssh my.user.server.com -l root /usr/bin/passwd --stdin username
Then every 2 hours, a cron job will execute this file and the users get added.
IS there any way of getting php to add a user straight away? Whenever I try to do it using the exec or passthru command, I get the following error in the apache error log:
useradd: unable to lock password file
Whats the easiest way of adding users on the fly?