Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2014-08-07
4
Medium Priority
?
1,221 Views
Last Modified: 2014-08-07
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
0
Comment
Question by:badwolfff
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Kent W
ID: 40246770
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 user.group,
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.
0
 

Author Comment

by:badwolfff
ID: 40246859
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 user.group.

thanks in advance
0
 
LVL 12

Accepted Solution

by:
Kent W earned 1000 total points
ID: 40246955
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
660.  
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.
0
 
LVL 31

Assisted Solution

by:serialband
serialband earned 1000 total points
ID: 40246994
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 .
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question