LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-03-2011, 03:31 AM   #1
MichaelGMorgan
LQ Newbie
 
Registered: Jan 2011
Posts: 14

Rep: Reputation: 0
Apaxhe/FTP User Permission Problem


Hello all,
I have a CentOS server running on Amazon EC2. I've set up Apache, PHP, etc and have also got FTP working. Apache runs as user "apache".

When I log into FTP (using user mgm, which I created) I'm not able to do anything. I can't upload, edit or delete anything, though I can download.

My "www" directory is stored at "/mnt/www/". This is not a shared server so I'm the only person who will ever be logging in so no need for multiple users here.

I just want to know how I can give my "mgm" user the right permissions to add, edit and delete via FTP. At the same time if PHP creates a file I need to be able to manage these via FTP also.

Currently, all PHP created files have owner "apache". The majority of the other files have owner "505" - which I assume is the ID of my "mgm" user, though not 100% sure.

How do I go about changing this?
Many thanks!
 
Old 01-04-2011, 05:13 PM   #2
thelastquincy
LQ Newbie
 
Registered: Apr 2009
Location: Chico, CA
Distribution: Ubuntu 10.10
Posts: 9

Rep: Reputation: 1
Quick question what application are you using for ftp?
 
Old 01-05-2011, 02:02 AM   #3
MichaelGMorgan
LQ Newbie
 
Registered: Jan 2011
Posts: 14

Original Poster
Rep: Reputation: 0
On the server, I'm not sure... vsftp isn't running and I couldn't find any other active FTP services. I port scanned and only 22 and 80 were open. If I'm thinking correctly, this means that all FTP is encrypted via SSH, right?

As a client I'm using WinSCP and logging in using SFTP.
 
Old 01-05-2011, 02:16 AM   #4
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 79

Rep: Reputation: 7
Quote:
Originally Posted by MichaelGMorgan View Post
Hello all,
I have a CentOS server running on Amazon EC2. I've set up Apache, PHP, etc and have also got FTP working. Apache runs as user "apache".

When I log into FTP (using user mgm, which I created) I'm not able to do anything. I can't upload, edit or delete anything, though I can download.

My "www" directory is stored at "/mnt/www/". This is not a shared server so I'm the only person who will ever be logging in so no need for multiple users here.

I just want to know how I can give my "mgm" user the right permissions to add, edit and delete via FTP. At the same time if PHP creates a file I need to be able to manage these via FTP also.

Currently, all PHP created files have owner "apache". The majority of the other files have owner "505" - which I assume is the ID of my "mgm" user, though not 100% sure.

How do I go about changing this?
Many thanks!
Hi,

Might be a write permission issue, check you /etc/passwd file and see the user and group ids for user mgm.
 
Old 01-05-2011, 02:29 AM   #5
120
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 9
First check. You have an FTP server running on the Cent server? Forget the fancy port scanning etc, if you are on the command line of that Cent server and type
Quote:
ftp 127.0.0.1
Do you get a banner and a prompt for a username/password?
 
Old 01-05-2011, 02:35 AM   #6
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 79

Rep: Reputation: 7
Also set the owner as, mgm for the folders which you are trying to upload, and make sure you have 755 for folders and 644 for files.
 
Old 01-05-2011, 05:25 PM   #7
MichaelGMorgan
LQ Newbie
 
Registered: Jan 2011
Posts: 14

Original Poster
Rep: Reputation: 0
@120 - Yes, I am prompted for username and password. It also told me it was vsFTPD 2.0.5

@siranjeevi - I took a look in the passwd file and the ID for user "mgm" is 500. I couldn't see the number 505 in there anywhere for any of the users. I know I could set the user to mgm for all of the folders/files within my www directory, but will this intefere with apache? Will this cause any issues with my sites? I really don't want to screw anything up and then having downtime for my sites. Currently they're working fine.

And then, what about when PHP creates/uploads a file - the file owner will be "apache", which means I wont be able to do anything with it without manually changing. My sites receive several hundred file uploads daily so this would be a real pain.

Thanks!
 
Old 01-05-2011, 10:44 PM   #8
120
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 9
Forgetting the issue of permissions for one moment because I'm concerned when you say 'nothing happens';

Crossing off the obvious:
When you FTP into the server from a remote location, do you also get that vsFTPD 2.0.5 banner?

Do you have any firewall issues with IPTABLES blocking port 20/21?
(Look with "iptables -nvL")

Do you have SELinux running in enforcing mode?
(Check with either: "sestatus" or "grep SELINUX /etc/selinux/config")

Does your remote client have some kind of Windowze Firewall/Security that is blocking incoming connections on port 20?
It may be worth checking your FTP client and setting it from 'Active' to 'Passive' to see if that helps

Finally, as far as permissions go - if you chmod your upload directory to 777 ("chmod 777 /your/upload/directory") that would normally allow anyone to write there (apache and all). That said, uploading via php is usually via the /tmp directory - so it would be interesting to see if your apache user can write to that. You can test that with something like: "sudo -u apache touch /tmp/caniwritehere.tmp" or "su apache -c "touch /tmp/caniwritehere.tmp" {change apache to mgm to test that}

This may, at least, put you into the ballpark of the failure. It is also worth looking at any logs for the FTP Daemon or the SELinux audit log: /var/log/audit/audit.log - perhaps the config or vsFTPD is worth looking at too. In the long run to put the correct permissions to an upload I'd look at setting a default umask for ftp. But don't run before you can walk.

HTH

Last edited by 120; 01-05-2011 at 10:53 PM.
 
Old 01-06-2011, 09:03 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608
Your "mgm" user account is an unprivileged user and as such it has no rights to access, read or write if permissions do not allow it. People will often (suggest you) weaken security by allowing everybody write rights to directories and files. Now a web server is a daemon that runs in its own account for several reasons, including security, and allowing it and everybody to write to directories it reads from probably is the best way to fsck up real good. While adding users to a common group may work to some extent the best option is to use POSIX ACL's (access control lists). Also see the Centos Deployment Guide: Setting Access ACLs.
 
Old 01-06-2011, 11:18 AM   #10
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 79

Rep: Reputation: 7
Quote:
Originally Posted by MichaelGMorgan View Post
@120 - Yes, I am prompted for username and password. It also told me it was vsFTPD 2.0.5

@siranjeevi - I took a look in the passwd file and the ID for user "mgm" is 500. I couldn't see the number 505 in there anywhere for any of the users. I know I could set the user to mgm for all of the folders/files within my www directory, but will this intefere with apache? Will this cause any issues with my sites? I really don't want to screw anything up and then having downtime for my sites. Currently they're working fine.

And then, what about when PHP creates/uploads a file - the file owner will be "apache", which means I wont be able to do anything with it without manually changing. My sites receive several hundred file uploads daily so this would be a real pain.

Thanks!
Listen, as long as the folder has read and execute permission to other users, and as long as files have read permission to other users the apache user can access the files in the folders, to allow PHP to upload contents you can follow a guide lines in this site "http://www.mysql-apache-php.com/fileupload-security.htm" and ok., if you don't want to take risk, we can stop doing this further.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User Permission and FTP KillaH425 Linux - Server 4 01-08-2009 01:46 AM
ftp user permission manish_meet_in Linux - Software 0 01-17-2008 03:28 PM
FTP file permission problem blueAlien Linux - Server 4 09-24-2007 11:09 AM
Limited permission on FTP user stefane321 Linux - Security 3 03-04-2005 07:21 PM
Ftp permission problem 360 Linux - Networking 4 02-19-2002 10:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration