I have an Apache server that will host several sites and a private web interface that aims to automate the deployment of a site from a git SSH URL. Those git repos are on the same machine, hold by a local Gitlab instance and owned by root, so SSH is needed (or I'm missing something).
So we have PHP running shell commands as www-data to clone publicly accessible websites from a root protected repo on the same machine.
Virtualhosts are managed with mod_vhost_alias
if that matters. I also do know about cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
.
But generating ssh keys for www-data doesn't seem like a great idea.
If I create a dedicated "web" user to that matter and generate ssh keys for it, then www-data can't clone in that directory. I can use ACL on the folder but it still doesn't get its ssh access.
Or maybe should I su web
with PHP at first ? In this case files wouldn't be owned by www-data which can cause sites not to work.
This reaches the point where I lose track of what's good and what's secure. I can find a working solution eventually but it won't be clean and probably won't be secure.
Additional info :
This is not a production server. All the sites (around 10 at once) will get a very limited traffic and most of them will be password protected anyway (I said "publicly accessible" above to cover the most extreme cases).
Development is made in a local environment, changes are pushed to the online version with git hooks.
There is only one web interface that can launch the deployment process. Only a few trusted users have access to it.
Deployment won't change Apache configuration as
mod_vhost_alias
will handle vhosts and nothing else is needed.All the sites will have a public folder, the rest of the files won't be accessible. Deployment script are already written at the time of deployment and can easily be used for this purpose.
Mid-deployment issues don't need to be addressed.