WinSCP problem with modifying files that belong to www-data while logged in as my_user

Hi all,

I have a Ubuntu 14 x64 server and I login to it using Putty and SSH key so I don't use the password.
I have WinSCP installed that gives me ftp access to the site using my private key.

My sites are all owned by www-data and my user is called "lupocatttivo".
In putty I use the sudo commando to execute everything and it all works.
However in WinSCP when I try to modify or delete any file that is not my property,
I get this error:
Permission denied.
Error code: 3
Error message from server: Permission denied

Open in new window

Is there anyway I could set WinSCP to allow me to modify files owned by any user (just like I do with sudo in putty)?

Could anyone help me?

thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent WSr. Network / Systems AdminCommented:
The user you are logging in as need to have write permissions.  
Assuming your WinSCP user is lupocatttivo -

So if you have a file test.txt with www-data.lupocatttivo as the,
Then set perms to 560 (the 6 is group, your lupocatttivo "group"), then you will be able to overwrite files as the lupocatttivo user/group.

Keep in mind your php perms (www-data user) would need 5 (r,x) or 6(r,w) depending on what php needs to do with files via the www-data user.
badwolfffAuthor Commented:
I don't exactly follow you.
I did this command on the whole joomla folder to own the files and give PHP the permission to write to filesystem:
sudo chown -R www-data:www-data /my_joomla_folder/

Do you mean to say that I should have done
sudo chown -R www-data:lupocatttivo /my_joomla_folder/     ?

If this is not so, then could you please explain more clearly? I use WINSCP and putty to login as lupocatttivo.
The joomla folder and files are owned by www-data. I don't know how to get them owned by www-data.lupocatttivo as the

thanks in advance
Kent WSr. Network / Systems AdminCommented:
Yes.  If your WinSCP user is lupocatttivo, then

sudo chown -R www-data:lupocatttivo /my_joomla_folder/

will make www-data the owner-user, and lupocatttivo the owner-group.  
The other side of that is chmoding the permissions.  The important part here for your lupocatttivo user is the second number (560 or whatever), you understand the first number is the owner-users perms (www-data), second number is owner-group (lupocatttivo), and third is all others.
4 = read (r--)
5 = read, execute (r-x)
6 = read, write (rw-)
7 = read, write, exectute (rwx)

So if www-data only needs r, lupocatttivo r,w, then
sudo chmod -R 460 /my_joomla_folder/
If you run into exectution problems, change the 4 to 5 (r,x)
sudo chmod -R 560 /my_joomla_folder/

Then, change the files www-data need to write to (via your other post) to
sudo chmod 660 /my_joomla_folder/file_that_needs_writes.ext

When you list files permissions (ls -a)
Example -

-r--rw---- 1 www-data   lupocatttivo    43 May  2 13:34 index.html

www-data is user, lupocatttivo  is group.
There are 10 dashes.  First one is a "d" if it's a directory, "-" if it's a file.
In the example above -
-     r--     rw-    ---  Is how it's broken down.  
Its a file (-), then next 3 tics,  r-- means user www-data has read, no w, no x (execute).
Next 3 after that (rw-) means the user lupocatttivo  has read, write, no x.
Last 3 (---) mean "All other users not named" have NO permissions (no r, no w, no x)

Root ALWAYS has rwx permissions unless you make it immutable.  But root can always immute / unimmute a file. Even if the owner/group is root.root and you set, say -r--------.  You will find root can still delete and do anything you want as root.  But don't get bogged down in immutable, it's rarely used.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
What user is your web server running as?  What group is it in?

There should be a group www-data that the user www-data belongs to.  Add your account to the group.

sudo useradd -G www-data lupocatttivo

Then cd to your web site root:  (assuming default)
cd /var/www

Add write permissions to the group.
chmod -R g+w .
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.