How do I set read-only permissions for SSH private key mounted files?

Last updated: September 15, 2025

Context

When using SSH private key files with Spacelift runners, the mounted files need specific read-only permissions to be accepted by SSH. By default, mounted files have 777 permissions, which are too permissive for SSH private keys and will be rejected.

Answer

To set the correct read-only permissions (600) for your SSH private key mounted file, follow these steps:

  1. Navigate to your stack settings

  2. Go to the Hooks tab

  3. Click "Add" under Before Init hooks

  4. Add the following command: chmod 600 /path/to/your/mounted/key

  5. Click Add to save the hook

Note: You need admin permissions on the stack to add hooks. If you don't see the "Add" option, ensure you have the correct permissions.