107 votes

ssh returns "Bad owner or permissions on ~/.ssh/config"

These commands should fix the permission problem: chown $USER ~/.ssh/config chmod 644 ~/.ssh/config Prefix with sudo if the files are owned by different user (or you don't have access to them). If ...
user avatar
  • 5,797
78 votes
Accepted

Why can I update a file owned by root using sudo vi, but not append a line to it with sudo echo "Thing" >> file?

Sudo elevates the process it calls, it does not elevate any of the current shell's processing like redirection, globbing, etc. The file redirection >> /etc/httpd/conf.d/vhosts.conf is being ...
user avatar
  • 128k
52 votes

Program file exists in /usr/bin, but cannot be used

/usr/bin/ngrok will be a symlink that points nowhere (or rather to a non-existing file). Check with ls -l.
user avatar
  • 96.4k
42 votes
Accepted

php script can't access /tmp folder

I found off why, well, someone gave me the global hint. It's neither the fault of php or tmpfs. The culprit was systemd and his security system PrivateTmp. For those who get in the same issue that I ...
user avatar
  • 741
35 votes
Accepted

What is a S-X-X-XX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXX-XXXX called in Windows security?

It's a SID, or Security Identifier. If it's showing the string rather than a "friendly name," it sounds like the new server doesn't recognize the account.
user avatar
34 votes
Accepted

Restrict a Linux user to the files he owns

Put a restricted and immutable directory between the outside world and the protected files, e.g. / ├─ bin ├─ home │ └─ joe <===== restricted and immutable │ └─ joe <== regular home ...
user avatar
28 votes
Accepted

How to add a file to a docker container which has no root permissions?

There is likely a way to view and change the Dockerfile for tomcat, but I can't figure it out after a few minutes. My inelegant solution is to add this line before the chown: USER root If you want ...
user avatar
23 votes

What is the most secure way to allow a user read access to a log file?

Just to expand a little on the above answers here is a real world use case. I run the enterprise log analysis application Splunk on a Redhat box. It runs under the splunk user and splunk group. This ...
user avatar
  • 631
21 votes
Accepted

OSX mojave: "crontab: tmp/tmp.X: Operation not permitted"

The short answer: Go to System Preferences > Security & Privacy and give Full Disk Access to Terminal. The long answer: Pull down the Apple menu and choose ‘System Preferences’ Choose “...
user avatar
  • 1,979
17 votes

ssh returns "Bad owner or permissions on ~/.ssh/config"

For me it was an issue with my user account not being the owner of the file sudo chown myuser ~/.ssh/config
user avatar
  • 271
16 votes

Stop users from saving files with specific extension in specific directories

You can use the 'File Resource Server Manager' role. Installation of this role is done from the "Server Manager". After the installation, enter the 'File Resource Server Manager' mmc console, and ...
user avatar
  • 1,230
15 votes

Restrict a Linux user to the files he owns

There is an option which you might want to consider (depending how much work you want to do for that). As others already posted, "normally" you cannot prevent someone with shell access to read world-...
user avatar
  • 2,841
15 votes

How to add a file to a docker container which has no root permissions?

Since Docker 17.09 one can use the --chown flag on ADD/COPY operations in Dockerfile to change the owner in the ADD/COPY step itself rather than a separate RUN operation with chown which increases the ...
user avatar
15 votes

Copy file permissions, but not files in Unix

GNU cp knows the --attributes-only flag since coreutils 8.6 --attributes-only don't copy the file data, just the attributes
user avatar
  • 1,037
15 votes
Accepted

Nginx doesn't have permission to access files with the same ownership

The nginx user is not able to traverse the filesystem to reach the folder where you have placed your site. A user must have the execute (+x) permission on a folder in order to be able to traverse it. ...
user avatar
  • 839
14 votes

Copy file permissions, but not files in Unix

My version of cp doesn't have the --attributes-only flag, so I worked up this. Briefly tested on simple folders, YMMV. $> ls version1/ version2/ $> ls -l version1/1/a -rw-rw-r-- 1 alex alex 0 ...
user avatar
  • 3,103
13 votes

What's the best way of handling permissions for Apache 2's user www-data in /var/www?

This question was asked again, and as discussed on meta, current best practices provides better approaches than there was available in 2009, when this was asked. This answer tries to give some current ...
user avatar
  • 41.9k
13 votes

ssh returns "Bad owner or permissions on ~/.ssh/config"

If on Windows Subsystem for Linux (WSL) and you pointed your WSL home directory to your Windows home directory (not recommended!) then chmod has no effect. Before you can chmod the files mentioned in ...
user avatar
13 votes
Accepted

Managing Security Groups for NTFS Permissions

Your thoughts are essentially what I do, and I've had a lot of success in managing things that way in complicated environments. The solution to both of the question is that you create resource groups ...
user avatar
  • 2,791
12 votes
Accepted

chmod: changing permissions of 'myscript.sh' : Operation not permitted

Set the permissions before you build the image chmod +x scripts/myScript.sh docker build . docker will keep the permissions when it copies the files.
user avatar
12 votes

chmod: changing permissions of 'myscript.sh' : Operation not permitted

Changing permissions of files you do not own in Linux requires root access, and the COPY command is most likely copying the file as root. You can change back to the sonarqube user after fixing the ...
user avatar
  • 4,989
11 votes

Restrict a Linux user to the files he owns

I have found POSIX Access Control Lists allow as you, as the system administrator, to protect your users from the worst of their own ignorance, by overriding the regular user-group-other file system ...
user avatar
  • 70.6k
10 votes

How to tell rsync do not check permissions

If you supply the -a flag -p is automatically included. If you specify --no-p all of the other options from -a remain intact.
user avatar
  • 201
10 votes
Accepted

How do I detect what is changing file ownership on Linux?

I think you can use audit for specific file/directory or you can write custom rule based on your requirement auditctl -w <path to the file you need to monitor> -p war -k test ...
user avatar
10 votes
Accepted

SFTP-server uploaded files having wrong rights

If an SFTP client does not specify permissions for uploaded files, the OpenSSH SFTP server assigns 0666 permissions to newly created files (minus the umask 0002 makes the 0664). This is hard-coded, ...
user avatar
10 votes
Accepted

What should be the right logs permissions for NGINX on CentOS?

On the files located in /var/log/nginx/ the rules have changed over the time (at least in my experience). Yet without more data I'm not comfortable giving a definitive suggestion. But I'll try. NGINX ...
user avatar
  • 116
10 votes
Accepted

how can I mount a windows share with rw access?

You can set the local UID using mount options, example below. You can find out your UID by running the id -u command. sudo mount -t cifs -o username=maazza,domain=MYDOMAIN,uid=1000 //192.168.123.2/...
user avatar
  • 9,330
9 votes
Accepted

Is ZIP archive capable of storing permissions?

From the unzip(1) manpage: Dates, times and permissions of stored directories are not restored except under Unix. (On Windows NT and successors, timestamps are now restored.) So yes, ...
user avatar
  • 38.5k
9 votes
Accepted

How to tell the difference between "No such file or directory" and "Permission Denied"

Test the file instead. test -e /etc/shadow && echo The file is there test -f /etc/shadow && echo The file is a file test -d /etc/shadow && echo Oops, that file is a ...
user avatar
9 votes
Accepted

Are directories with mode `drwxrwxrwt` safe in /tmp on a *nix system?

drwxrwxrwt (or 1777 rather than 777) are the normal permissions for /tmp/ and not harmful for subdirectories in /tmp/. The leading d in the permissions drwxrwxrwt indicates a a directory and the ...
user avatar
  • 70.6k

Only top scored, non community-wiki answers of a minimum length are eligible