Question

I'm facing an annoying problem. It's been pretty frustrating. I am using a computer at my school to work on the Coursera Startup class. I am trying to connect to an Amazon EC2 instance. I downloaded the key pair. I check permissions.

mac5-library:startup roh21$ ls -l
total 6
-rw-rw-rw-@ 1 roh21  108  1692 Jun 22 16:45 startup-class-key.pem

So, it's not secure. So I need to change the permissions. I try:

mac5-library:startup roh21$ chmod 400 startup-class-key.pem
mac5-library:startup roh21$ ls -l
total 6
-r--r--r--@ 1 roh21  108  1692 Jun 22 16:45 startup-class-key.pem

Still has read permissions to everyone. Just to demonstrate what happens I do this:

mac5-library:startup roh21$ chmod 600 startup-class-key.pem
mac5-library:startup roh21$ ls -l
total 6
-rw-rw-rw-@ 1 roh21  108  1692 Jun 22 16:45 startup-class-key.pem

Is it impossible to change permissions to the user without root permission? I'd be grateful for any kind of help.

Était-ce utile?

La solution 2

I copied the file to my ~/.ssh folder and then changed the permissions with chmod. That did it.

Just to provide more information, the permissions for the ssh folder,

drwx------    8 roh21  108      272 Jun 26 17:26 .ssh

And the permissions to the folder I used initially

drwxrwxrwx    2 roh21  108     2048 Jun 23 06:32 startup

I curious as to why I could not change the permissions to the startup folder even after multiple attempts with the chmod -R option.

Also, note that I was using Mac OS X in my school's library.

Autres conseils

Probably not related to initial questions problem, but can be useful. (especially to Unix novices like myself)

Chmod will not work if you are not an owner of resources.

You should run chown first:

$ sudo chown -R $(whoami) .

and then

$ sudo chmod -R +rwX .

First command will change owner of everything in current folder to be logged in user, and second give them read write execute permissions. Just for example, you, probably, should not change ownership and permissions so boldly.

Looks like you've discovered that the Macintosh doesn't strictly agree with the UNIX permission bits.

Ultimately, there are ACL bits that MacOS sets and that the Macintosh Finder obeys.

To solve your problem quickly, in your Terminal command line, type in "open ." (or the path to your "startup" folder) and that will open up the folder in your Macintosh Finder.

Then do a "Get Info" on the file: Sharing & Permissions

You can change your permissions here.

See that '@' next to the mode flags? That means that there's extended metadata associated with the file. Use ls -l@ to see it. The xattr command will let you view and modify them. It's possible that there's something there that prevents you from modifying the file.

There may also be additional file flags. Use ls -lO (capital-O) to view those. Odds are that one of those flags is the "uchg" flag which means your file is immutable. You can remove that with chflags nouchg <filename> as أحمد طه suggested.

Finally, there might be an ACL attached to the file. Use ls -le to see that.

In general, if you really want to know all the metadata associated with a file on a Mac, the command is ls -leO@.

Hello And it will work

chflags nouchg /path/folder/
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top