Why AWS EC2 Recommends chmod 400 Instead of chmod 600 for .pem Keys
chmod 400 (-r--------) grants read-only access exclusively to the file owner while denying every bit to group members and other users. That is why AWS EC2 launch instructions specify chmod 400 my-key.pem before running ssh -i: OpenSSH refuses any private key readable by group or others ("WARNING: UNPROTECTED PRIVATE KEY FILE!"), and removing the owner write bit adds an extra safety net against accidentally overwriting or truncating an irreplaceable keypair.
Be careful never to apply chmod 400 to a directory (dr--------), because listing or opening files inside a Linux directory requires the execute (+x) traversal bit (use 500 or 700 for directories). If you are on WSL2 and chmod 400 appears to do nothing on /mnt/c/.../key.pem, copy the key into the native Linux filesystem (~/.ssh/) where POSIX mode bits are enforced.
- Symbolic Mode-r-------- (file) · dr-------- (directory) · Octal 0400
- Permission BitsOwner: r-- (4) · Group: --- (0) · Others: --- (0)
- OpenSSH CompliancePASS — satisfies OpenSSH StrictModes for private key files
Should I use chmod 400 or chmod 600 for SSH private keys?
Both pass OpenSSH security checks. Use chmod 400 for static downloaded keys like AWS EC2 .pem files (read-only safety), and chmod 600 for ~/.ssh/id_ed25519 or ~/.ssh/config when ssh-keygen or editors need to update them.
Why does chmod 400 key.pem fail to change permissions in WSL on Windows?
Windows NTFS mounts under /mnt/c do not store Linux permissions by default unless mounted with metadata. Move the key into ~/.ssh/ inside your WSL Linux home directory and run chmod 400 there.
Can I delete a file that has chmod 400 permissions?
Yes. Unlinking (rm) a file depends on write permission on its parent directory, not on the file itself—though rm will prompt for confirmation on write-protected 400 files.