-4

I am trying to make UNIX account for the users on my website, but i don't know how to get php to make the accounts or log in. I have tried the shell_exec() command, but i don't know how to give it a password. Thanks.

2 Answers2

1

Although it is certainly possible to coerce a server into allowing PHP via an HTTP request to create users, it is a security nightmare to setup and I highly recommend against it. You would need to defeat a number of security features built into modern Linux & Unix systems to make this work.

Instead I would probably handle this by running a frequent cron job that looks for new users in your database and creates a UNIX account for them via shell scripting.

The script would:

  • Query your database for users created in the last few minutes
  • Run useradd to create their accounts
  • Run a password generation utility to set their passwords.

Beware: There will be a lot of maintenance associated with this. Only undertake this if you are certain you understand the potential security and maintenance implications and you really trust your users.

You may have lots and lots of unused shell accounts piling up. You would want a script that regularly cleans out/removes the unused ones. You would want to maintain a password expiry policy for the Unix accounts. You may want to lock down the access those shell accounts had to a subset of commands to prevent anyone registered on your website from using their shell accounts to turn your server into a spambot. I could go on and on...

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
0

Maybe you need ssh connection using php. But you have to be careful with permissions

Nidis
  • 71
  • 2