TechEarl

Fix SSH "Permissions Are Too Open" (UNPROTECTED PRIVATE KEY FILE)

SSH refuses your key with WARNING: UNPROTECTED PRIVATE KEY FILE. The one-line fix is chmod 600, plus the full set of ~/.ssh permissions and ownership SSH actually checks. Linux, macOS, Windows.

Ishan Karunaratne⏱️ 6 min readUpdated
Share thisCopied
The SSH UNPROTECTED PRIVATE KEY FILE error, what causes it, and the exact chmod that fixes it, on Linux, macOS and Windows.

SSH just refused your key with a wall of @ symbols and WARNING: UNPROTECTED PRIVATE KEY FILE!. The fix is one line: tighten the private key so only you can read it.

bash· Linux (GNU)
chmod 600 ~/.ssh/id_ed25519

That clears the error immediately. The rest of this page is the why, the full set of permissions SSH checks, and the ownership trap that chmod alone does not fix.

Try it with your own values

Pick your OS. The commands below switch to the right form (chmod on Linux/macOS, icacls on Windows).

What the error actually says

Run anything that loads the key and SSH stops you cold:

Terminal showing chmod 644 on a private key, then ssh-keygen reporting WARNING: UNPROTECTED PRIVATE KEY FILE, Permissions 0644 are too open, the key will be ignored, then chmod 600 to fix it.
Permissions 0644 means group and other can read the key, so SSH ignores it. chmod 600 makes it owner-only and the warning is gone.

The number in the message (0644, 0640, 0444, whatever yours is) is the current mode. Anything that grants group or other a single bit on a private key trips the check. SSH then refuses to use the key and falls back to the next auth method, which is usually why you also see Permission denied (publickey).

Why SSH is this strict

A private key is a secret. If any other account on the machine can read the file, they can copy your key and impersonate you on every server that trusts it. So OpenSSH refuses to load a private key whose permissions let anyone but the owner read it. On the server side the same rule is enforced by StrictModes, which is on by default in sshd: a world-writable ~/.ssh or authorized_keys gets silently ignored, and you are left wondering why key auth "stopped working."

This almost always shows up after you copied keys from another machine (a backup, a new laptop, a Docker bind mount, a cloud sync folder) and the loose permissions came along for the ride. Freshly generated keys already have the right modes; see how to create an SSH key for that flow.

The full set of permissions SSH expects

Fixing the private key clears the immediate error, but ~/.ssh has several files and SSH checks all of them. Set the lot:

bash· Linux (GNU)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/config

Here is what each file should look like on Linux and macOS:

PathModeMeaning
~/.ssh700only you can enter the directory
~/.ssh/id_ed25519 (private)600only you can read or write the key
~/.ssh/id_ed25519.pub (public)644public, safe for anyone to read
~/.ssh/authorized_keys600the keys allowed to log in as you
~/.ssh/config600may contain hostnames and key paths

A correct ~/.ssh looks like this:

ls -la of ~/.ssh showing the directory at drwx------ (700), the private key at -rw------- (600), and the public key at -rw-r--r-- (644), all owned by the user.
700 on the directory, 600 on the private key, 644 on the public one, all owned by you.

chmod is not enough if the owner is wrong

chmod sets the mode, but SSH also checks who owns the file. If the key is owned by root (the classic result of running sudo ssh-keygen), no amount of chmod as your normal user will help, because you cannot even change a file you do not own. Fix the owner first:

bash· Linux (GNU)
sudo chown -R $USER:$USER ~/.ssh && chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519

One more owner-level trap: your home directory must not be group- or world-writable either. If chmod 700 ~/.ssh did not help, check ~ itself with ls -ld ~ and tighten it (chmod g-w,o-w ~). sshd walks the whole path and refuses keys sitting under a loosely-permissioned home.

Windows: it is ACLs, not chmod

Windows OpenSSH does not use Unix modes. It checks NTFS ACLs, and the error text is the same. The fix is to strip inherited permissions so only your account (and SYSTEM/Administrators) can read the key, which is what the icacls ... /inheritance:r /grant:r commands above do. A key in your own %USERPROFILE%\.ssh is usually scoped correctly already; you mostly hit this after copying a key in from elsewhere.

FAQ

See also

Sources

Authoritative references this article was fact-checked against.

TagsSSHssh-keygenFile PermissionschmodLinuxmacOSWindowsSecurity

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Tech Architect · Software Engineer · AI/DevOps

Tech architect and software engineer with 20+ years building software, Linux systems, and DevOps infrastructure, and lately working AI into the stack. Currently Chief Technology Officer at a healthcare tech startup, which is where most of these field notes come from.

Keep reading

Related posts

Fix SSH "Permission denied (publickey)"

The ordered checklist for SSH Permission denied (publickey): is the key loaded, is it the right key, is the public half on the server, and are the server-side permissions sane.

Fix SSH "Host Key Verification Failed"

Why SSH warns that the remote host identification has changed, when it is safe to clear, and the one command that removes the stale known_hosts entry: ssh-keygen -R.