WARNING:
THIS IS POTENTIALLY INSECURE
&
SHOULD NOT BE DONE IN MOST CIRCUMSTANCES
In this how-to I will provide a one-time version and a shorter over time version. For the latter one, I assume you know how to use chmod. One-Time
Code:
$ su
Password:
# su -s /bin/bash www-data
Congrats, you're now logged in as www-data! Regular Basis Create 2 files & make them executable:
/usr/sbin/to-www
/usr/bin/auto-www
Contents of /usr/sbin/to-www:
Code:
#!/bin/sh
su -s /bin/bash www-data
Contents of /usr/bin/auto-www:
Code:
#!/bin/sh
su -s '/usr/sbin/to-www'
To log in as www-data from a regular user, just run 'auto-www' and input the root password. For a sudoer, you can run 'sudo to-www' or 'auto-www' But why would you want that? For me it was the fact that I host multiple sites and they are managed by the perspective people and some scripts refuse to work with ownership of user:www-data * cough cough drupal cough cough * thus not allowing one user per site. However I did not want to open www-data to SSH and I wanted the individual users to start in their site's directory. So I did this and set their shell to /usr/bin/auto-www, gave them the root password, and added the -p option to both files. Note: What I did it is not viable unless you trust your users like I do.