chmod 700
rwx------Safe when used as intended
Only the owner can read, write and execute.
700 is fully private: the owner can do anything, and no other user — apart from root — can list, enter, read or run anything.
It's required in a few places. OpenSSH's StrictModes checks that ~/.ssh isn't writable by anyone else, and GnuPG warns when ~/.gnupg is accessible to others.
Permission by permission
| Who | Read | Write | Execute | Digit | Means |
|---|---|---|---|---|---|
| owner | ✓ | ✓ | ✓ | 7 | read, write and execute |
| group | — | — | — | 0 | no permissions |
| others | — | — | — | 0 | no permissions |
- In
ls -l:-rwx------for a file,drwx------for a directory. - Symbolic form:
u=rwx,g=,o= - New directories get this mode when the umask is
077.
Use it for
~/.sshand~/.gnupgdirectories.- Private scripts only you should run.
- Directories holding secrets, backups or personal data.
Avoid it for
- Anything a service running as another user must read.
- Private files that aren't programs: use
600.
Commands
chmod 700 path
set this mode on a file or directory
chmod u=rwx,g=,o= path
the same, written symbolically
find path -type d -exec chmod 700 {} +apply it to every directory in a tree, leaving the files alone
stat -c '%a %A %n' path
check the current mode on Linux (macOS: stat -f '%Lp %Sp %N' path)
Try variations
| Who | read | write | execute | Digit |
|---|---|---|---|---|
| owner | 7 | |||
| group | 0 | |||
| others | 0 |
The owner can read, write and execute; the group can do nothing; everyone else can do nothing.
chmod 700 file
chmod u=rwx,g=,o= file
Frequently asked questions
What permissions should ~/.ssh have?
700 for the ~/.ssh directory, 600 for private keys and authorized_keys, and 644 for public keys (.pub). Too-open permissions make sshd ignore authorized_keys or ssh refuse a key.