سؤال

I can't chmod group permission in Cygwin on Windows 8 so that I can't ssh connect to a server using an ssh key.

Bash prompt warning: "Permissions 0660 for '/home/KeepZero/.ssh/id_rsa' are too open. It is required that your private key files are NOT accessible by others."

KeepZero@t400win8 ~
$ ls
test

KeepZero@t400win8 ~
$ ls -l
total 0
-rwxrwx--- 1 KeepZero KeepZero 0 Mar  4 15:07 test

KeepZero@t400win8 ~
$ chmod 700 test

KeepZero@t400win8 ~
$ ls -l test
-rwxrwx--- 1 KeepZero KeepZero 0 Mar  4 15:07 test

KeepZero@t400win8 ~
$ chmod 777 test

KeepZero@t400win8 ~
$ ls -l test
-rwxrwxrwx 1 KeepZero KeepZero 0 Mar  4 15:07 test
هل كانت مفيدة؟

المحلول

Do an ls -al and you will see that your files do not belong to any group (none).

Just do a chgrp Users * on your files, and you are fine again.

نصائح أخرى

Roi Danton's solution works, however it does not solve the root cause, and the issue will recur with any user-created file on which you want to change the permissions.

To fix the problem permanently:

  1. Look up the group ID of the "Users" group in /etc/group (or the equivalent group name for your locale).

    In my installation this was 545 (your mileage may vary). cat /etc/group|egrep '^Users:' will get you the correct line. The third field on the line is the group id. (cat /etc/group|egrep '^Users:'|cut -f3 -d':' to just get the id).

  2. Edit your /etc/passwd file. Locate the record for your user. The fourth field is the "primary group" for the user. It is incorrectly set to a non-existent group. Change that number to the number you found in step 1 above. Save the etc password file.

  3. Close any open Cygwin windows/terminals and then open a new one. Create a new file. It should have a group of "Users", and you should be able to change its permissions as desired.

A possible reason of this problem is that you have copied your .ssh folder on the actual pc...

Create your own folder, and then you get the right user group. Don't copy folders... they are assigned to user groups that don't match.

I had the same problem on Windows Server 2012 R2. After trying to change the owner or group or even the permissions of a file it still showed the original values and ignored my settings.

After reading File permissions,

File permissions

On NTFS and if the noacl mount option is not specified for a mount point, Cygwin sets file permissions as on POSIX systems.

I figured out that the noacl option was set for the mountpoins:

$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,noacl)
C:/cygwin/lib on /usr/lib type ntfs (binary,noacl)
C:/cygwin on / type ntfs (binary,noacl)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,noacl,auto)

So I removed the noacl option from the mountpoints in /etc/fstab and closed all Cygwin windows. After reopening the console the permission setting with chown, chgrp, and chmod worked as expected.

I faced the same issue in Windows 10 in the Cygwin command prompt.

For the id file, only the root user should have full permission and for other users restricted/no permissions should be fine.

The below command solves the issue,

 chmod 700 <id-file>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top