chmod 700: Private Directories Such as ~/.ssh
700 is rwx------: only the owner can read, write, list, enter or execute. It is the correct mode for a private directory such as ~/.ssh or ~/.gnupg, and it is what SSH checks for before it will use the keys inside.
At a glance
- Octal
- 700, written 0700 in four digit form
- Symbolic
- u=rwx,g=,o=
- On a file
- -rwx------
- On a directory
- drwx------
- Owner
- Read, write, execute
- Group
- Nothing
- Others
- Nothing. Cannot list, cannot enter, cannot open a known path
In detail
700 is the private directory mode. Nothing outside the owning account can list the names, traverse into it, or reach anything below it, no matter how open the contents are. That last part is the useful property: a 644 file inside a 700 directory is unreachable by other accounts, because the path cannot be resolved past the directory.
SSH depends on this. With StrictModes on, which is the default, the daemon refuses to use ~/.ssh/authorized_keys if the directory or the home directory is writable by anyone but the owner, and the client refuses to load a private key whose mode is too open. The result is a plain authentication failure on the client side and a line in the server log that people rarely think to check.
It is also the right mode for anything holding local state you would not want another account reading: ~/.gnupg, ~/.aws, ~/.kube, a directory of database dumps, a scratch area used by a cron job. Combine it with 600 on the files inside and there is no path by which another local account reaches the contents.
The catch is that 700 blocks services too. A web server that needs to read something under a 700 home directory cannot, and no mode on the inner file will change that. Either move the content somewhere the service can traverse, or open the specific directory to 711 so it can pass through without being able to list.
Directories deeper in the tree do not override a 700 parent. Permissions are checked at every component of the path, so the most restrictive step decides the outcome. When a permission denied makes no sense, run namei -l on the full path and read the modes from the root downwards.
Examples
chmod 700 ~/.ssh
chmod u=rwx,g=,o= ~/.sshdrwx------ alice alice /home/alice/.ssh/
-rw------- alice alice /home/alice/.ssh/id_ed25519
-rw-r--r-- alice alice /home/alice/.ssh/id_ed25519.pub
-rw------- alice alice /home/alice/.ssh/authorized_keys
The home directory itself must not be group or world
writable either, or StrictModes rejects the whole lot.Things that catch people out
- SSH also checks the home directory, not just ~/.ssh. A home directory at 775 causes authorized_keys to be ignored while ~/.ssh itself is a perfect 700.
- 700 on a home directory stops a web server reaching a personal web directory inside it. 711 on the home directory is the usual compromise, since it allows traversal without listing.
- Copying a directory with cp without -p resets modes from the umask, so a 700 directory can silently become 755 after a copy or a restore from an archive that did not preserve permissions.
- root ignores the mode entirely. A 700 directory keeps other unprivileged accounts out and does nothing against an administrator or a process running as root.
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 600: Owner Only Read and Write for Keys and Secrets
600 gives the owner read and write and nobody else anything. The mode SSH, PostgreSQL and other tools insist on for files holding credentials.
chmod 711: Directories You Can Enter but Cannot List
711 gives others execute without read, so they can enter a directory by exact name but cannot list it. Where this is used and what it does not protect.
chmod 750: Owner Writes, Group Reads, Others Shut Out
750 gives the owner everything, the group read and traverse, and everyone else nothing. The right mode for application directories that must stay private.
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 666: World Writable Files and the Few Legitimate Ones
666 lets every account read and write the file with no execute bit anywhere. Why it is wrong for regular files and right for a handful of device nodes.
chmod 664: Group Writable Files for Shared Work
664 lets the owner and the group edit a file while everyone else can only read it. The default on systems using a 002 umask and per-user groups.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder