- Permission denied in FTP even though I’m the owner
- linux permissions / chown vs ftp
- 1 Answer 1
- Linux FTP/SSH Permissions
- 2 Answers 2
- Keeping file permissions with FTP
- 3 Answers 3
- How to manage Linux permissions for users, groups, and others
- Linux security
- Setting up a playground
- How do I create directories and files?
- How do I manage ownership and groups?
- How do I manage permissions?
- How do I use absolute mode?
- More Linux resources
- How do I use symbolic mode?
- Special permissions and Access Control Lists
- Wrap up
Permission denied in FTP even though I’m the owner
Okay, so I’ve tried my best at finding the answer to this by searching and looking through possible duplicates, but I just can’t so forgive me if it’s out there somewhere anyways.
My issue is as follows. I’ve set the owner of /var/www to myuser:www-data and permissions of the folder and all (currently just the basic index.html) it’s content to 750 , and Apache seems to run it as supposed, but I can’t access it when I FTP into the server as the myuser user. I mean, I can access it, but as soon as I try to edit, delete or add something I just get 500 Permission denied , and if I try to edit the permissions I get 500 Unknown SITE command .
Help! What do I do wrong? The idea on setting the user and group, and then the permissions as above was from a good friend of mine who is sort of an expert, but I feel like I’m bothering him when I ask so many questions, so if you can help me some more, that would be great!
I’m trying to put a backup with 4 vhosts back into the www-folder, but what I put there shouldn’t be of any concern, right? That’s just the confing of the vhosting later that has got anything to do with that, right?
Thanks in advance!
I ran this: myuser@myserver:/$ groups myuser And got this: myuser : myuser adm cdrom sudo dip plugdev lpadmin sambashare Then I ran this: myuser@myserver:/$ groups www-data And got this: www-data : www-data
And then this: myuser@myserver:/var/www$ ls -l And got this: total 4 -rwxr-x— 1 tjita1 www-data 177 Jan 25 17:45 index.html
Regarding the ftpserver, I didn’t do anything in particular, I just installed vsftpd. Oh yeah, I also added a line in I think /etc/vsftpd.conf or something like that, that reads something like this: chmod_enable=YES .
Also, I can’t get those 4-space-indents to work, sorry about that..
Источник
linux permissions / chown vs ftp
I have (I guess basic) problems with Linux permissions/ownership.
I have FTP user «ftp». Then I have all files on my server under different user «nginx».
To make the websites work I need to have all files set to user nginx otherwise they return various errors.
To change files on the server on FTP I need to have permissions set to user «ftp» otherwise I get permissions denied when I try to edit the files.
How to solve this with?
Right now I have to always do chown -R ftp:ftp when I want to edit some files through FTP.
1 Answer 1
It sounds like you need a common group for both ftp and nginx. In your case you can probably use the ftp group for this. I don’t know if your web server needs write access to the files, but if not, cd into your content directory and run these commands:
If you do need write access from web server, do this instead:
These commands will make everything owned by ftp:ftp and make these files readable and (in the second case) writable by anyone in the ftp group. It also sets the setgid bit on all the directories which will make all new files owned by the ftp group. Once this is done, add the nginx user to the ftp group:
and restart your web server so it will take effect.
You may also need to force all files written to these directories to be writable by the group. You can do this by setting the umask for your ftp and web servers to 002, or with an acl:
Источник
Linux FTP/SSH Permissions
I’m not incredibly familiar with how to properly setup permissions. Currently we sudo everything on the server because otherwise we don’t have permission. I just got FTP up and running and I don’t have permission to create a directory within a wordpress installation. I’m noticing everything there is.
I know I shouldn’t be able to change root files, but why does root own everything? The server guy that used to be here and set all this up is gone. Is this the best way or should we have a «webdev» group or something?
2 Answers 2
You definitely want a group for this. I would configure a group for FTP access. Put the users in a group that you want to use for FTP users, and then I suggest the following (assuming the FTP group is called FTP and the base data directory is /ftpdata — change these as needed):
Here’s what you’re doing.
This sets the owner to nobody and the group to ftp for every file and directory below /ftpdata.
This command sets every file below /ftpdata to be mode 664, that is read-write for the owner and group, and read-only for everyone else.
This command sets every directory below /ftpdata to 2775, that is read-write-and-execute for the owner and group, and read-execute for the world, plus any new files created in any of those directories will be owned by the ftp group.
The 2 in 2775 is «Set Group ID» — whenever a new file is created in a directory with that bit set, it makes the group of that file the same as the group that owns the directory. Without that, a user who’s primary group is not the ftp group will create files that are owned by another group, and may not be accessible by other members of the group.
Источник
Keeping file permissions with FTP
Is there a way I can upload my files from my computer to my server without losing the permissions? Everything is linux.
3 Answers 3
You are aware that ftp is not the program to use on the internet in 2011. The password will be send in cleartext. (In a wired or WPA Enterprise protected wireless network you might be OK as long as all your traffic stays inhouse)
sftp is the secure replacement (based on ssh). put and get commands have the -P option to preserve the permissions.
Basically all FTP clients (cute, filezilla, smart, yafc, etc) have the option to set file permissions.
I have not yet seen any feature / option to permanently persist the file permissions from your computer to the server. However you can in filezilla and in cuteftp ( i use these 2) set an advanced property which will auto apply a permission set of your choice to all files uploaded.
Also, i think this is not likely to ever be released as a feature since file permissions are also based on user! Different users on your computers and different users on your server all of which may or may not have differing permissions.
Hope this helped. Cheers.
PS: let me know if you can’t find the option in filezilla or cuteftp
It depends on your FTP client. I’m sure nearly all FTP clients have this option. For example, my favorite command-line FTP client, Yafc, lets you:
Источник
How to manage Linux permissions for users, groups, and others
Photo by Min An from Pexels
Managing access to resources is a fundamental task for sysadmins. This responsibility consists of three components: identities, resources, and permissions. This article covers several user, group, and file management commands to control access to resources. The article uses a «How do I…?» format, and it assumes you have a few resources to work with. Specifically, I cover the following topics:
- Creating directories and files
- Managing ownership and associated groups
- Setting permissions with absolute and symbolic modes
Linux security
Setting up a playground
I’ve been in IT for about 25 years, and most of that time was spent as a technical trainer. That means that the things that I write are usually structured as some sort of lab or other hands-on opportunity. It’s just how I cover material. With that in mind, I’ll assume you have a couple of identities and resources to experiment with as you read the rest of the article. You can use the following commands to set up a playground. It’s best to do this on a virtual machine rather than your personal Linux box, but these tasks are relatively harmless.
Create two new users and two new groups to work with. Note that you do not need to configure passwords for the users in this exercise, as you won’t log on with those accounts.
Note: You would use the passwd user01 command to set the user’s password.
In your home directory, create a new directory named playground :
Change into the
/playground directory by using the cd command. You are ready to work with the commands and concepts below.
When you’ve completed the article and learned the techniques I’ve covered, delete the two user accounts, the groups, and the playground directory. Use rm -fR /playground , userdel user01 , and groupdel groupA to remove the resources.
How do I create directories and files?
Use the mkdir command to create directories. The touch command is one of many ways to create files.
How do I create a directory named Resources ?
How do I create a directory path (a series of directories that don’t yet exist)?
Note: The goal here is to create the 2020data directory, but the given path’s data directory does not yet exist. The -p option creates parent directories as needed to complete the path.
How do I create a file named file1 ?
How do I create several files at once?
How do I manage ownership and groups?
In the playground directory, display the current owner and group associated with the Resources directory and the files.
How do I display permission, owners, and groups?
The ls -l command displays directory contents in long format. The long format contains both permissions and ownership. You can see that the user account that created the resources also owns those resources. The group association is also that user’s primary group.
How do I change the user/owner associated with file1 ?
How do I change the group associated with file1 ?
How do I change the owner and group at the same time for file2 ?
There is a specific chgrp command, but I prefer only to memorize one command ( chown ) and apply it to both functions (user and group associations) rather than chown for the user and then have to recall chgrp for the group.
So how do I use chgrp ?
How do I change the user/group for a directory and all of its contents?
The above task provides a recursive configuration. Technically, recursive commands are repeated on each specified object. Effectively, recursive means «this and everything in it.» In the above example, you are configuring the related user/group for the Resources directory and everything in it. Without the -R option, you would only affect the Resources directory itself, but not its contents.
How do I manage permissions?
The change mode or chmod command sets permissions. The syntax is straight-forward:
Here are two examples of manipulating permissions for file2 :
But wait! Those appear to be radically different examples (they’re not, actually). What are all those letters and numbers?
We need to discuss absolute mode and symbolic mode.
How do I use absolute mode?
Absolute mode is one of two ways of specifying permissions. I’ve seen this mode referred to as octal or numeric mode, but the term I learned was absolute. That term also makes the most sense to me because it’s an absolute statement of the desired permissions. I always told my students that this seemed like the most complex of the two modes but is actually the simplest. Usually, they agreed.
Each access level (read, write, execute) has an octal value:
Access level | Octal value |
Read | 4 |
Write | 2 |
Execute | 1 |
Each identity (user, group, others) has a position:
Identity | Position |
User | First or left-most |
Group | Middle |
Others | Last or right-most |
More Linux resources
The absolute mode syntax states the desired permissions from left to right.
How do I grant the user (owner) read, write, and execute, the group read-only, and all others no access to file2 by using absolute mode?
The three permissions values are associated with identities:
ugo
740
- The 7 is assigned to the user and is the sum of 4+2+1 or read+write+execute (full access)
- The 4 is assigned to the group and is the sum of 4+0+0 (read-only)
- The 0 is assigned to others and is the sum of 0+0+0 (no access)
In this example, the user has rwx, the group has r only, and all others have no access to file2 .
Let’s look at one more example.
How do I grant the user (owner) read and write, the group read-only, and all others read-only to file2 ?
- The user has 6 (read and write)
- The group has 4 (read-only)
- All others have 4 (read-only)
I find this easier because there are no calculations involved. I’m not concerned with adding or subtracting specific permissions based on the current settings. Instead, I say, «set the permissions to be this,» and that’s the end result I get. It’s an absolute statement.
How do I set permissions for the Resources directory and all of its contents by using absolute mode?
How do I use symbolic mode?
Symbolic mode uses more symbols, but the symbols are simpler to understand. That’s attractive to sysadmins that are new to standard Linux permissions.
Each access level has a symbol:
Access level | Symbol |
Read | r |
Write | w |
Execute | x |
Each identity has a symbol:
Identity | Symbol |
User | u |
Group | g |
Others | o |
There are also operators to manipulate the permissions:
Task | Operator |
Grant a level of access | + |
Remove a level of access | — |
Set a level of access | = |
The general chmod command syntax is the same:
Here is an example:
How do I remove the read permissions from others for file2 by using symbolic mode?
This example removes ( — ) the read ( r ) permission from others ( o ) for file2 .
Here’s another simple example:
How do I grant the read and write permissions to the group for file2 ?
This one gives ( + ) read and write ( rw ) to the group ( g ) for file2 .
How do I set permissions for a directory and all of its contents by using symbolic mode?
Special permissions and Access Control Lists
The above discussion covers standard Linux permissions—applying rwx to the user, group, and all others. Linux has far more flexibility, however. Special permissions permit users to run applications with other credentials, control the inheritance of group associations, and keep files from being changed accidentally. Check out this great article on special permissions.
Linux also has a way of enforcing different permissions for different users and groups. Access Control Lists (ACLs) permit sysadmins to define permissions for more than just one user and one group, which adds a great deal more flexibility to standard permissions. For example, user01 can be granted rw- to file1 , while user02 can be granted r— to file1 . Here is a great article on ACLs.
Wrap up
Creating resources, managing users, and setting permissions are fundamental tasks for Linux users. My goal was to provide a quick and easy guide based on common questions or tasks that we must all accomplish regularly. If you’re new to Linux, having a solid grasp of the eight commands discussed above will make your sysadmin life much easier.
Источник