chmod 600 vs 700 Meaning: SSH Keys, Folders & .env Files
Why does SSH demand chmod 700 on ~/.ssh/ but chmod 600 on private keys and .env files? Learn the exact permission bits so servers never lock you out.
chmod 600 (rw-------) gives only the file owner read and write access, while chmod 700 (rwx------) adds the execute bit (+x). Both lock out group members and all other system users completely.
Here is the fast rule: use 700 on private directories (like ~/.ssh/) so you can enter them, and use 600 on sensitive files (like id_ed25519 or .env) that should never be executed as programs.
To inspect octal bits or generate copy-paste permission commands interactively, try our chmod calculator for 700.
Why do folders need chmod 700 instead of 600?
On Linux and macOS, the execute bit (1, x) means something completely different on a directory than on a regular file. On a file, x lets the kernel run it as a script or binary; on a folder, x means traverse permission (cd into the folder and read files inside it).
If you accidentally set chmod 600 ~/.ssh, your own user gets Permission denied trying to open id_ed25519 inside it!

Compare every single bit between 600 and 700:
| Octal Mode | Symbolic String | Owner (u) |
Group (g) |
Other (o) |
Typical Use Case |
|---|---|---|---|---|---|
600 |
-rw------- |
Read + Write (4+2) |
None (0) |
None (0) |
.env, ~/.ssh/id_ed25519, .pgpass |
700 |
drwx------ |
Read + Write + Traverse (4+2+1) |
None (0) |
None (0) |
~/.ssh/, ~/.gnupg/, private script bins |
644 |
-rw-r--r-- |
Read + Write | Read (4) |
Read (4) |
Public configs, SSH .pub files |
Why OpenSSH and PostgreSQL reject keys with wider permissions
Programs that handle secret credentials check permissions before reading them. If a key or .pgpass file is readable by group or other (such as default 644), ssh refuses the connection with Permissions 0644 for '~/.ssh/id_ed25519' are too open.
For exact step-by-step recovery when an existing key throws that warning, check our guide on fixing SSH unprotected private key file errors.
Apply the standard two-line lock-down whenever setting up a new server or workstation:
# Lock private directory (owner can traverse + modify entries)
chmod 700 ~/.ssh
# Lock private keys, SSH config, and local secrets (no execute bit)
chmod 600 ~/.ssh/id_ed25519 ~/.ssh/config .env
Remember to keep your public key (~/.ssh/id_ed25519.pub) at 644. You share public keys freely, while private keys, PostgreSQL .pgpass credentials, and .env secrets stay strictly 600. When creating files automatically inside scripts, run umask 077 first so newly written secret files start at 600 before anyone can read them.
Avoid accidental chmod -R 600 on folders
Never run recursive chmod -R 600 ~/.ssh or chmod -R 600 ./secrets. Recursive 600 strips the traverse bit (x) off subdirectories, breaking your SSH client, Python virtual environments, or Docker secrets mounts immediately.
Use find when locking down nested folders separately from nested files:
# Set every subdirectory inside ./secrets to 700
find ./secrets -type d -exec chmod 700 {} +
# Set every secret file inside ./secrets to 600
find ./secrets -type f -exec chmod 600 {} +
Notice chmod u=rwX,go= with an uppercase X is another neat Unix shortcut: uppercase X grants x only to directories (or files that already had x), sparing plain .env files while keeping nested folders traversable.
chmod 600 vs 700 FAQ
Should .env files in production be chmod 600 or 640?
Use 600 owned by the exact user running your app service (for example www-data or node). Only switch to 640 if a separate deploy user owns .env and your runtime group needs read-only access.
Does chmod 600 stop root or sudo from reading my file?
No. root (UID 0) bypasses standard discretionary UNIX permissions and can read 600 files. Restrict sudo access on shared hosts or encrypt secrets at rest when root isolation is needed.
Why did ~/.ssh/id_ed25519 keep 600 after git checkout, or fail on WSL?
Git only tracks a single executable bit, not 600 vs 644. On Windows WSL (DrvFs) mounts, Linux chmod can silently do nothing unless /etc/wsl.conf enables metadata support (options = "metadata").
Verify any octal code or permission flag combination interactively in the ToolQuilt chmod calculator.