chmod 600: Owner Only Read and Write for Keys and Secrets
600 is rw-------: only the owner can read or write, and no other account can read a single byte. It is the required mode for an SSH private key and the correct mode for any file holding a credential that only one account needs.
At a glance
- Octal
- 600, written 0600 in four digit form
- Symbolic
- u=rw,g=,o=
- On a file
- -rw-------
- On a directory
- drw-------, which the owner cannot even enter
- Owner
- Read and write
- Group
- Nothing
- Others
- Nothing. No other unprivileged account can read the contents
In detail
600 is the secret file mode. An SSH private key, an API token file, a database password file, an environment file used by one account: all of them want the owner to read and write and nobody else to have any access. Combined with a 700 directory it produces a path no other unprivileged account can reach at any step.
Several tools enforce it rather than merely recommending it. The SSH client refuses to load a private key whose mode allows group or other access and prints an explicit warning about an unprotected key file. PostgreSQL ignores a .pgpass file that is group or world accessible. The curl configuration in .netrc is treated the same way by some tools. In each case the symptom is a login failure rather than a permissions error.
The distinction from 640 is one question: does another account have to read this. If a service running under a different user must read the file, use 640 and set the group correctly. If not, 600 is strictly better, because it removes an entire class of accounts from the picture rather than trusting group membership to stay correct.
On a directory, 600 is a trap. Without the execute bit even the owner cannot traverse into it, so the read bit lets you list the names while every attempt to stat or open an entry fails. A private directory is 700, and the missing digit is exactly the traverse permission.
Note what 600 does not do. It is not encryption: root reads the file regardless, a backup copies it in the clear, and anything running as your own user reads it freely, which includes any program you install. For a secret that must survive a stolen disk or a compromised account, encrypt it rather than relying on a mode.
Examples
chmod 600 ~/.ssh/id_ed25519
chmod u=rw,g=,o= ~/.ssh/id_ed25519@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'id_ed25519' are too open.
Fix:
chmod 600 ~/.ssh/id_ed25519-rw------- ~/.ssh/id_ed25519
-rw------- ~/.ssh/authorized_keys
-rw------- ~/.netrc
-rw------- ~/.pgpass
-rw------- ~/.my.cnf
-rw------- /srv/app/.env (or 640 with a service group)Things that catch people out
- 600 on the key is not enough if ~/.ssh or the home directory is group writable. SSH checks the whole path with StrictModes and refuses on the loosest component.
- 600 on a directory locks out the owner, because listing without traversing is useless. Directories want 700.
- The public half of a key pair does not need 600. Setting it stops nothing and occasionally confuses tooling that expects the public key to be readable at 644.
- Restoring from an archive, copying with cp without -p, or checking a file into version control all lose the mode. Reapply 600 after any of those before the file is used.
Try it: Chmod Calculator
Tick the nine permission boxes, or type an octal or symbolic value, and get the three digit and four digit octal, the ls -l rendering and the exact chmod command back.
Chmod Calculator
LOCAL · Browser-OnlyCalculate Unix file permissions with an interactive chmod builder
Permission Matrix
| Entity | Read (4) | Write (2) | Execute (1) | Octal | Symbolic |
|---|---|---|---|---|---|
| Owner (u) | 7 | rwx | |||
| Group (g) | 5 | r-x | |||
| Others (o) | 5 | r-x |
Special Bits
Advanced permission flags for executables and directories
Generated Permissions
755rwxr-xr-x-rwxr-xr-xchmod 755 filenamechmod u=rwx,g=rx,o=rx filenamePermission Breakdown
Owner (u)
7rwx- - Read files / list directory contents
- - Write / modify / delete
- - Execute / traverse directory
Group (g)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Others (o)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Common Permissions Reference
| Octal | Symbolic | Meaning |
|---|---|---|
777 | rwxrwxrwx | Full access for everyone |
755 | rwxr-xr-x | Owner full, others read and execute |
750 | rwxr-x--- | Owner full, group read and execute |
700 | rwx------ | Owner full access only |
666 | rw-rw-rw- | Read and write for everyone |
644 | rw-r--r-- | Owner read/write, others read only |
600 | rw------- | Owner read/write only |
555 | r-xr-xr-x | Read and execute for everyone |
444 | r--r--r-- | Read only for everyone |
400 | r-------- | Owner read only |
Related File permissions
All file permissions →chmod 700: Private Directories Such as ~/.ssh
700 gives the owner read, write and execute and everyone else nothing. Why SSH insists on it for ~/.ssh and what breaks when a parent is more open.
chmod 640: Configuration Files a Service Group Can Read
640 gives the owner read and write, the group read only, and everyone else nothing. The correct mode for configuration holding credentials.
chmod 400: Read Only Keys and Downloaded PEM Files
400 gives the owner read and nothing to anyone else, not even write. The usual mode for a downloaded cloud key pair and how it differs from 600.
chmod 644: The Default File Mode and When to Change It
644 gives the owner read and write and everyone else read only. Why it is the default for files under a 022 umask, and the cases where it is wrong.
chmod 555: Read and Execute With No Write for Anyone
555 removes the write bit from the owner as well as everyone else. What that protects against, what it does not, and how real immutability is done.
chmod 550: Programs a Service Can Run but Cannot Change
550 gives the owner and group read and execute and everyone else nothing. The mode for a privileged script that a service must run but must not modify.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder
- AES Encryption Tool Free online AES encryption tool - encrypt and decrypt text using AES-256 encryption