/System/Library/LaunchAgents is locked in El Capitan

I'm trying to achieve this: Make my password protected SSH key expire or timeout after a while

In Yosemite, this worked fantastic, in El Capitan, using sudo, the files in /System/Libary/LaunchAgents is completely locked :( I cannot chmod, write, or chown the files.

Using Finder -> Get info, the locked checkbox is disabled for the folder and the files in it (changing owner using finder doesn't work too).


Solution 1:

El Capitan adds a new security feature named System Integrity Protection (SIP). Among other things, SIP prevents parties other than Apple from adding, deleting or modifying directories and files stored in certain directories:

/bin
/sbin
/usr
/System

Apple has indicated that the following directories are available for developers to access:

/usr/local
/Applications
/Library
~/Library

All directories in /usr except for /usr/local are protected by SIP.

Solution 2:

In my case, it was the new System Integrity Protection feature in El Capitan. I disabled that in recovery mode using this link :

  1. Boot into recovery mode
  2. Click Utilities at the top, and then Terminal
  3. Type in csrutil disable