Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why cannot I chmod in Cygwin on Windows 8 CP?

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 
like image 202
KeepZero Avatar asked Mar 05 '12 04:03

KeepZero


People also ask

How do I fix Permission denied in Cygwin?

The fix was to set the shortcut to "Run as Administrator". If you are using this method to access your Cygwin environment, go to the properties of the shortcut, select the Advanced button to get the options to "Run as Administrator", check the box, click Ok. And off you go!!

Does chmod work on Windows?

chmod is a command in Unix and Unix-like operating systems that are used to change the access permissions of files and directories. The name is an abbreviation of change mode, which does not exist in Windows OS.


2 Answers

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.

like image 145
Roi Danton Avatar answered Sep 17 '22 15:09

Roi Danton


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.

like image 39
Robert Avatar answered Sep 17 '22 15:09

Robert