NYCPHP Meetup

NYPHP.org

[nycphp-talk] SSH2_CONNECT

Ajai Khattri ajai at bitblit.net
Thu Jul 30 17:05:00 EDT 2009


On Thu, 30 Jul 2009, Michele Waldman wrote:

> Will sudo work from the php script?  That would work for me.
> 
> Basically, I'm looking through domain names gotten from mysql and copying
> files from a template directory in one domain to the other domains.
> 
> Sudo has been setup for the user, but I didn't know if it would work or how
> it works or what function to use from php?

Basic Unix Permissions 101:

Most probably your PHP script will be running under the same username as 
Apache (i.e. www or nobody) so sudo wouldn't work anyway. (And you 
wouldn't want to give www or nobody sudo privilege anyway!).

Another solution is to create a group that both the web server user and 
the destination folder belong to and give the group write permissions. But 
there are downsides to this too (basically if your script is hacked it 
would allow anyone to write to any folder that has group write 
permissions).

This is probably why the Joomla installer switched to using FTP back to 
the same host to install files - it gets round all the problems since you 
just login as a regular user and don't have to mess with sudo or groups.

So, it sounds like using FTP or SSH back to the same host with the other 
username is a good strategy.


 
-- 
Aj.




More information about the talk mailing list