I'm creating a web app which will allow me to setup shared hosting environments. Everything has to be done programmatically and i'm questioning whether i'm approaching things in a completely insecure way.
At the moment i'm creating bash scripts to install and configure each user, and then executing those scripts from the webserver. However, I keep having to run commands as sudo in the scripts.
For example, after creating a user, I need to log in as that user and download something with wget. In order to get to this point I'm running adduser as sudo, then piping in the password from an environment variable, and then running sudo su to log in as that user. All of that feels very questionable, but I have yet to figure out an alternative.
Any help at all would be much appreciated!