Page 1 of 1

SFTP and SUDO or SU on Ubuntu

Posted: Mon 13 Dec 2010 16:14
by snorkel
Hi,
Is it possible to execute a SUDO -i or SU to allow the SFTP to upload as a different user id?
Reason I ask is it makes it more convenient to upload files that are supposed to be owned by the web server, for example on Ubuntu www-data.
If I can switch to that user I don't have to mess around with changing the owner and permissions after I upload a file.

Posted: Tue 14 Dec 2010 10:00
by Dimon
SFTP protocol doesn't allow to change user. To solve the problem you can try starting SSH/SFTP server with access rights of superuser.

Posted: Tue 14 Dec 2010 17:22
by snorkel
I found a simple solution.
I just added a new non privileged user and set it's user and group ID to the same as the web server, since my app only uses one user it works perfectly.

Posted: Wed 15 Dec 2010 08:30
by Dimon
It is good to see that this problem has been solved.