Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

SSH "WARNING: UNPROTECTED PRIVATE KEY FILE!" "Permissions 0644 for 'id_ed25519' are too open": make the key private to you, on Linux or Windows

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When ssh prints a banner of @ characters with "WARNING: UNPROTECTED PRIVATE KEY FILE!", then "Permissions 0644 for 'id_ed25519' are too open." (ssh prints the file name as it was given, so a real run often shows a full path), the client refuses to use that key. The next lines say "It is required that your private key files are NOT accessible by others." and "This private key will be ignored." On Linux and macOS the fix is a file mode that gives group and others nothing; on Windows it is an access list that names only you. Check first who owns the file and which other account reads it.

What the message means

The ssh(1) manual says the private key files "should be readable by the user but not accessible by others (read/write/execute)" and that "ssh will simply ignore a private key file if it is accessible by others."

OpenSSH 9.9p2 (tag V_9_9_P2) implements that in sshkey_perm_ok in authfile.c. It prints the banner and the three sentences when two things hold: the file is owned by the user running ssh, and the mode has any bit of group or others set (st_mode & 077). A file owned by someone else does not trigger it; the source comment, which wraps over two lines, says "if the key owned by a different user," on one line and "then we don't care." on the next. The mode in the second line is printed in octal, so 0644 means read and write for the owner and read for group and others.

A further line follows in sshconnect2.c: Load key "<file>": bad permissions, where bad permissions is the text ssherr.c gives to SSH_ERR_KEY_BAD_PERMISSIONS. The wording "bad permissions: ignore key" that older guides quote is not in that tag. Our own reading: once the key is skipped, ssh tries other identities, and if none is accepted it ends with Permission denied (publickey); that is covered in SSH "Permission denied (publickey)": what the server log says and what to fix.

On Windows the PowerShell/openssh-portable source at v9.5.0.0 calls check_secure_file_permission instead of the mode test and prints "Permissions for '%s' are too open." without an octal number. The Win32-OpenSSH wiki page says private keys "need to be owned by the user and no other user should have access to user's key files."

Likely causes

Cause What you see How to confirm
Key created or copied with a permissive mode Mode 0644 or 0664 on Linux or macOS ls -l shows letters in the group or others columns
Key copied from another system, a zip or a share Mode 0777 or 0755 ls -l
Windows ACL inherited from a shared folder Other users or groups listed icacls lists more than your account
Key on a filesystem that cannot hold Unix modes chmod appears to do nothing ls -l unchanged after chmod; our own reading
Key owned by another account No warning, but ssh cannot read it ls -l shows a different owner

Prove the cause before changing anything

Steps 1, 3 and 4 only read. Step 2 opens a real connection, which is not a read-only act: answer no to a host-key prompt you did not expect, and type exit if a shell opens.

1. Read the mode and owner on Linux or macOS. The long listing shows them; the first column is the mode:

ls -l ~/.ssh/id_ed25519

A private key that passes shows read and write for the owner only, -rw-------, which is 0600. Letters after the first three characters mean group or others have access.

2. Run the failing connection verbosely. ssh(1) says -v prints debugging messages and that more -v options raise the level, to a maximum of 3:

ssh -v -i ~/.ssh/id_ed25519 deploy@app01.example.com

The -i option selects the identity file that is read. The Load key line names the exact file ssh refused; a configuration file may be selecting a different key from the one you expect.

3. Read the Windows owner and access list. The Win32-OpenSSH wiki page uses (get-acl <file>).owner for the owner, and the icacls page says the command displays the DACL:

(get-acl C:\Users\admin01\.ssh\id_ed25519).owner
icacls C:\Users\admin01\.ssh\id_ed25519

A good result is your own account as owner and only your account in the list. Any other user or group, including a group such as Users that arrives by inheritance, is the fault.

4. Check that something else does not rely on the loose mode. A backup job, a deployment runner or another login may read the same key through its group access. Tightening the mode removes that access.

Fix

Linux and macOS

First save the current state:

ls -l ~/.ssh/id_ed25519 > key-mode-before.txt

Risk: the next command removes all access to the key for the key's group and for everyone else. Any other account or service that reads this file through group or other access will stop being able to.

Set the mode to read and write for the owner only. The chmod(1) manual builds an octal mode from values such as 0400 (owner read) and 0200 (owner write), so 0400 + 0200 gives 0600:

chmod 0600 ~/.ssh/id_ed25519

Only if you need to back out, and knowing that the key becomes readable by group and others again and ssh refuses it again: set the octal mode that the warning printed, which is the mode that key-mode-before.txt records in letters, then list the file and compare it with the saved listing. Each group of three letters is one digit, with r as 4, w as 2 and x as 1; -rw-r--r-- is 6 (4 + 2) for the owner, 4 for the group and 4 for others, which is 0644.

Risk: the next command gives the key's group and others back the access it had before. The key becomes readable by them again, and ssh refuses it again.

chmod <octal mode read from key-mode-before.txt> ~/.ssh/id_ed25519

The source test also passes for 0400, because the group and others bits are zero (st_mode & 077 is 0). The same manual page recommends that ~/.ssh itself has read, write and execute for the user and nothing for others.

Windows

First save the current state:

icacls C:\Users\admin01\.ssh\id_ed25519 /save C:\Users\admin01\key-acl-before.txt

Risk: the next three commands rewrite the access list of one private key file. Microsoft's icacls page says the r inheritance value "Disables inheritance and removes only inherited ACEs", so any account whose access came only through inheritance, such as backup tools or other administrators, loses it.

Remove inheritance, remove an explicit entry for each other user, and grant yourself read:

icacls C:\Users\admin01\.ssh\id_ed25519 /inheritance:r
icacls C:\Users\admin01\.ssh\id_ed25519 /remove EXAMPLE\otheruser
icacls C:\Users\admin01\.ssh\id_ed25519 /grant:r EXAMPLE\admin01:(R)

EXAMPLE\otheruser stands for an account the earlier icacls listing showed; run that line once for each such account, and not at all if the listing shows none.

Our own advice: the Win32-OpenSSH wiki shows /inheritance:r and /remove for host keys and authorized_keys, and the icacls page shows /grant:r; the same forms apply to a user key. Microsoft's icacls page spells the inheritance option /inheritancelevel with values e, d and r; run icacls /? to see which spelling your build prints. The icacls page says /grant:r makes the new permission replace earlier explicit ones.

Only if you need to back out, and knowing that this overwrites the access list the key now carries and ssh refuses the key again: restore the saved list, then read the access list again.

Risk: the next command overwrites the access list that the key's directory entries now carry with the saved one, so inherited access and the other accounts' entries return, and ssh refuses the key again.

icacls C:\Users\admin01\.ssh /restore C:\Users\admin01\key-acl-before.txt

The /restore form applies the saved list to the directory it was saved from. The owner is not changed by any of these commands. If the owner is wrong, the wiki shows icacls <file> /setowner for host keys; changing ownership of a user key is a separate change that needs its own save, warning and back-out.

Example (illustrative): ci01 runs ssh -i ~/.ssh/deploy_key deploy@app01.example.com and prints "Permissions 0644 for '/home/build/.ssh/deploy_key' are too open." followed by Permission denied (publickey). ls -l shows -rw-r--r-- owned by build; the same group also holds the release account, which reads the key during a nightly job. The administrator saves the listing, confirms with the owner of release that the nightly job can use its own key instead, then sets 0600. The connection now loads the key and the server's own log decides the rest.

Confirm the fix

  1. ls -l shows -rw------- (Linux and macOS), or icacls lists only your account (Windows).
  2. ssh -v -i ~/.ssh/id_ed25519 deploy@app01.example.com no longer prints the banner or the Load key ... bad permissions line. This is a real connection: answer no to a host-key prompt you did not expect, and type exit if a shell opens.
  3. To check that the key itself is intact, use ssh-keygen -y -f ~/.ssh/id_ed25519. The ssh-keygen(1) manual says -y reads a private OpenSSH format file and prints the public key; a passphrase prompt is normal.

What to watch afterwards

Risks and limits

  • These commands have not been run or lab-tested.
  • Removing group and other access can stop other accounts that share the key; find them before changing the mode.
  • The OpenSSH source readings are for tags V_9_9_P2 and v9.5.0.0; other releases may word the message differently.
  • The man.openbsd.org pages show no version or date; they describe the current OpenBSD OpenSSH.
  • The ssh(1) page also says ~/.ssh/config must not be writable by others; that gives a different message and is not covered here.

Sources

  • ssh(1) — OpenBSD manual pages, no date shown, accessed 3 December 2026
  • chmod(1) — OpenBSD manual pages, no date shown, accessed 3 December 2026
  • ls(1) — OpenBSD manual pages, no date shown, accessed 3 December 2026
  • ssh-keygen(1) — OpenBSD manual pages, no date shown, accessed 3 December 2026
  • authfile.c — OpenSSH portable source, tag V_9_9_P2, no date shown, accessed 3 December 2026
  • sshconnect2.c — OpenSSH portable source, tag V_9_9_P2, no date shown, accessed 3 December 2026
  • ssherr.c — OpenSSH portable source, tag V_9_9_P2, no date shown, accessed 3 December 2026
  • authfile.c — PowerShell/openssh-portable (Win32-OpenSSH) source, tag v9.5.0.0, no date shown, accessed 3 December 2026
  • Security protection of various files in Win32 OpenSSH — Win32-OpenSSH wiki on GitHub, 14 January 2019, accessed 3 December 2026
  • icacls — Microsoft Learn, 9 June 2025, accessed 3 December 2026