chmod 400 Linux Permissions Calculator

Symbolic: -r-------- · Owner read-only · Standard for AWS EC2 .pem private keys

chmod 400 (0400) LOW RISK SSH KEY VALID
4-digit: 0400
Dir: dr--------
Presets:
Interactive Permission Matrix (3×3 + Special Bits) -r--------
Scope Read (4) Write (2) Execute (1) Digit Sum
Owner (u) 4(r) = 4
Group (g) 0 (none)
Others (o) 0 (none)
Special Mode Bits (4th Leading Octal Digit) 0 (none)
File / Dir Symbolic
-r-------- / dr--------
Binary Bitmask
100 000 000
umask Complement
Dir 377 · File 266
umask 266 creates files as 400 (dirs as 511).
Security Audit & Command Builder
Clean Least-Privilege Permission Set: Mode 400 restricts write access to the owner and avoids world-writable or SUID escalation risks.
OpenSSH Audit (SSH KEY VALID): Passes OpenSSH StrictModes (400 hides private keys from group/others). Recommended for ~/.ssh/id_ed25519, id_rsa, and AWS .pem keys.
Apply Permission (Octal & Symbolic)
chmod 400 aws-key.pem
Symbolic: chmod u=r,g=,o= aws-key.pem
Recursive chmod -R
chmod -R 400 aws-key.pem
Safe Recursive Split (Dirs vs Files via find)
find aws-key.pem -type d -exec chmod 500 {} +
find aws-key.pem -type f -exec chmod 400 {} +
Verify Permissions with stat
stat -c "%a %A %U:%G %n" aws-key.pem
macOS/BSD: stat -f "%Op %Sp %Su:%Sg %N" aws-key.pem
Side-by-Side Octal Comparison
Open /chmod/600/ →
Property chmod 400 (-r--------) chmod 600 (-rw-------)
Octal (3/4-Digit)400 (0400)600 (0600)
File Symbolic-r---------rw-------
Directory Symbolicdr--------drw-------
Owner (u)Read (4)Read, Write (6)
Group (g)None (0)None (0)
Others (o)None (0)None (0)
Special BitsNoneNone
Binary Bits100 000 000110 000 000
Matching umaskDir: 377 / File: 266Dir: 177 / File: 066
Security RiskLOW RISKLOW RISK
SSH Private KeySSH KEY VALIDSSH KEY VALID
Common Use CaseProtecting AWS EC2 .pem private keys, TLS private key files, and immutable owner-only secrets against both unauthorized reads and accidental edits.Owner read/write only (OpenSSH private keys, ~/.ssh/authorized_keys, .env)
chmod 400 · -r-------- umask 377 (dir) / 266 (file)
Ctrl+Enter: Copy chmod · 100% Browser-Local
Advertisement
Reserved fixed-height slot (CLS = 0.00) 728×90 320×100 300×50

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.