Link to home
Start Free TrialLog in
Avatar of choccarlm
choccarlm

asked on

Adding a user using php

Hi,

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?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of jnbkze
jnbkze
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CleanupPing
CleanupPing

choccarlm:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
CleanupPing

That was extremely rude and unprofessional.