A private SSH key that’s readable by other users may be rejected by OpenSSH. On Linux and macOS, chmod 600 is a common fix—but it’s worth knowing what the number means, when it applies, and what it doesn’t protect against.
Read the permission number
Unix permission numbers have three digits: owner, group, and others. Each digit combines read (4), write (2), and execute (1). So 6 means read plus write, while 0 means no permissions.
That makes 600 equivalent to:
owner: read, write
group: none
others: none
For a regular file, ls -l displays this as -rw-------. The first character is - because it’s a regular file; the next nine characters show the permissions.
To try it safely, use a disposable file:
printf 'demo only\n' > test-secret.txt
chmod 600 test-secret.txt
ls -l test-secret.txt
stat -c '%a %n' test-secret.txt # GNU/Linux
You should see -rw------- from ls and 600 test-secret.txt from GNU stat. macOS uses a different stat syntax:
stat -f '%Lp %N' test-secret.txt
chmod 0600 filename has the same ordinary owner/group/other permission effect as chmod 600 filename. You can also express it symbolically:
chmod u=rw,go= filename
Why SSH private keys often use 600
A private key is a credential. If group or other users can read it, OpenSSH may warn that the key has “bad permissions” or is “too open,” then ignore it. The check happens on the machine where the key file lives—not on the remote server.
For a typical Linux or macOS setup, these are common safe defaults:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
Use the path to the key you actually intend to use; a downloaded key might instead be somewhere like ~/Downloads/server.pem. Mode 400 is also often suitable for a private key: it gives the owner read access but not write access. Both 400 and 600 deny ordinary group and other access.
The .pub file is the public key, not the private credential, so it doesn’t need the same restriction. Don’t confuse it with the private key that has the same name but no .pub suffix.
If SSH still fails after correcting the mode, that doesn’t prove the key is valid for the server. You may be using the wrong key, the matching public key may not be authorized, or another authentication issue may be involved. For that next step, see this guide to diagnosing SSH public-key permission errors.
A file mode is not a directory mode
The x permission has a different practical role on directories: it allows traversal, or searching the directory for entries. A private SSH directory commonly uses 700, not 600:
600 regular file: -rw-------
700 directory: drwx------
Applying 600 to a directory removes its execute/search permission. Even its owner will typically be unable to enter it. Avoid commands like chmod -R 600 on a project: they can make directories unusable and remove execute permissions from scripts.
A private key and its containing directory also aren’t the only SSH files to consider. For example, ~/.ssh/config should not be group- or world-writable. These practical SSH config examples can help when organizing settings for multiple hosts.
When 600 is the wrong choice
600 means the owner can read and write the file, while ordinary group and other permissions are removed. That may break an application that reads the file as a different user.
For example, if a deployment account owns an .env file but a web service runs as www-data, setting the file to 600 can prevent the service from reading it. Check the file’s owner and the process’s runtime identity before changing permissions. A controlled group-readable mode such as 640 may fit some setups, but the right choice depends on which account needs access.
You can inspect a file and your current identity with:
id
stat -c '%a %U %G %n' .env
A mode of 600 also isn’t encryption. It restricts ordinary local file access, but it does not protect a secret from root, malware running as the file’s owner, or someone who copied it before permissions were fixed. If a key may have been exposed, changing its mode doesn’t revoke it; replace the key and remove the old public key from systems that trusted it.
Windows uses ACLs, not a universal chmod equivalent
Windows file access is controlled with NTFS access-control lists (ACLs), not Unix permission digits. There isn’t one chmod 600 number that translates to the correct Windows permissions in every case.
For a Windows OpenSSH key, inspect its access rules in PowerShell before making changes:
$key = Join-Path $env:USERPROFILE '.ssh\id_ed25519'
Test-Path $key
icacls $key
Get-Acl $key | Select-Object Owner, AccessToString
These commands inspect the file; they don’t change its permissions. The intended account and any inherited access entries matter, so don’t blindly remove ACL entries. Also, don’t assume that running chmod in Git Bash has restricted the NTFS ACL used by native Windows OpenSSH. In WSL, behavior depends on whether the file is in the Linux filesystem or on a Windows-mounted drive.
A quick check before changing permissions
For a Unix-like system, start with the specific file and verify the result:
stat -c '%a %U %G %n' ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ls -l ~/.ssh/id_ed25519
Use 600 for an owner-only file, 700 for a private directory, and verify that the user or service that needs the file can still access it. If the mode looks right but access is still failing, check ownership, parent-directory traversal, ACLs, and which account is running the process.
I originally published a more detailed version of this guide on the ShadeTerm blog.
I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.
Top comments (0)