'How do you disable permission inheritance of a file using Ruby on Windows?

How do you disable permission inheritance on a file using Ruby on Windows?

I am attempting to secure an SSH private key that is generated by kitchen-ec2 so that only the user has access as attempting to use it as-is throws an error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'C:/chef_cookbook/.kitchen/tomcat-amazon2.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "C:/chef_cookbook/.kitchen/tomcat-amazon2.pem": bad permissions
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source