Fixing an Unprotected Private Key File SSH Error
How to fix an unprotected private key file SSH error
Run chmod 600 ~/.ssh/id_rsa on Linux or macOS to restrict an unprotected private key file for SSH so only you read it. SSH actively ignores key files readable by other users.

When you attempt to connect to a remote server using SSH and encounter the warning about an unprotected private key file, OpenSSH refuses to proceed. OpenSSH refuses to proceed immediately. The SSH protocol treats loose file permissions as a critical security risk. If a local user or a compromised process can read your private key, your entire cryptographic identity is exposed. Instead of logging you in with that key, the client ignores it. Furthermore, it may continue with other authentication methods (simplified.guide).
How to fix unprotected private key file SSH on Linux and macOS
For Linux and macOS, you fix an unprotected private key file SSH error by running chmod 600 on the key file. You also run chmod 700 on the containing ~/.ssh directory.
Execute the following exact commands in your terminal to secure your environment:
-
- Run
chmod 700 ~/.sshto restrict access to your SSH configuration directory. You should see no output if the command succeeds. - Run
chmod 600 ~/.ssh/id_rsa, replacingid_rsawith your specific private key file name. Verify the change by runningls -l ~/.ssh, which should display permissions as-rw-------for the key file.
- Run
How to fix unprotected private key file SSH Windows
On Windows systems, you fix an unprotected private key file SSH error by opening the file properties, navigating to the security advanced settings, removing inherited permissions, and granting full control exclusively to your user account.

- Open PowerShell or File Explorer, right-click your private key file, select Properties, and go to the Security tab.
- Click Advanced, then click Disable inheritance to convert inherited permissions into explicit permissions on this object.
- Remove all entries except your own user account and SYSTEM, leaving only your user account with Full Control.
Warning unprotected private key file SSH windows and PowerShell
When running OpenSSH via PowerShell on Windows, you often encounter the warning permissions for 'id_rsa' are too open. Windows file systems default to inheriting permissions from parent folders. These inherited permissions grant read access to groups like Users or Authenticated Users. Because OpenSSH checks for strict POSIX-style permissions, any extra access triggers the warning.
You resolve this in PowerShell by using the built-in icacls utility. This tool strips inherited permissions and isolates access to your current user account.
- Open PowerShell and navigate to the folder containing your key.
- Run
icacls id_rsa /c /t /inheritance:dto disable inheritance on the file. - Next, Run
icacls id_rsa /c /t /grant %username%:Fto grant full control exclusively to your user profile. - Run
icacls id_rsa \/c \/t \/remove Administrators SYSTEM Usersto strip unwanted groups. Doing this ensures only your user SID retains permissions.
How to handle ssh-keygen unprotected private key file issues
When you generate a new key pair using ssh-keygen, the tool normally applies the correct secure permissions automatically. However, if you run ssh-keygen inside a shared directory, a custom Docker volume mount, or a misconfigured virtual machine shared folder, the underlying file system may ignore standard permission bits.

To prevent ssh-keygen from creating vulnerable files, you always generate keys directly inside your native user home directory (such as ~/.ssh/ on Linux or C:\Users\YourName\.ssh\ on Windows) rather than external drives or shared network folders that lack native POSIX or NTFS permission support.
Can you use ssh unprotected private key file ignore workarounds?
You cannot configure OpenSSH to ignore the unprotected private key file warning via a command-line flag or a configuration file directive. The OpenSSH development team hardcoded this security check to prevent users from accidentally exposing credentials.
If you attempt to bypass this by writing wrapper scripts or changing source code, you introduce severe security vulnerabilities into your infrastructure. You must fix the underlying file permissions instead of seeking an ignore switch.
How to use ssh-add unprotected private key file solutions
When you run ssh-add ~/.ssh/id_rsa and receive the unprotected private key file warning, the SSH agent refuses to load the key into memory. Fixing the file permissions clears the blockage immediately.

- Run your permission fix command (
chmod 600on Unix oricaclson Windows). - Restart your SSH agent service. Run
ssh-add -k ~/.ssh/id_rsato force the agent to re-read the secured file. - Verify the key loaded successfully by running
ssh-add -lto list active keys in your agent.
Who this advice does not suit
This guide targets standard developers and system administrators managing local private keys on Linux, macOS, or Windows workstations. This advice does not suit containerized build pipelines running as root where keys must be injected dynamically, shared CI/CD runner environments that require ephemeral key generation, or hardware security modules (HSMs) and YubiKeys where private keys never touch the local file system.
Related guides
Frequently asked questions
Is SSH completely secure?
SSH provides strong cryptographic security for data in transit and authentication. Its overall security depends heavily on protecting your private keys from local theft and using modern key types like Ed25519.
How to protect a private key?
You protect a private key by storing it exclusively on trusted local devices, encrypting it with a strong passphrase, and setting strict file system permissions such as read and write access for the owner only.
What does ssh-keygen do?
The ssh-keygen utility generates, manages, and converts authentication keys for SSH. It allows you to create secure public and private key pairs for server access.
How to fix SSH permission denied?
You fix SSH permission denied errors by verifying your public key is added to the remote server’s authorized_keys file, checking your private key permissions, and ensuring correct user authentication methods are enabled on the server.