WARNING: UNPROTECTED PRIVATE KEY FILE: Permissions are too open (SSH on a Mac)
Frank Zhang
- 4 minutes read - 1918 wordsTL;DR
The client skips a private key the current user owns when group or others can access the file. Read that path with ls -l, chmod 600 it, and retry the same command.
Match this warning before you generate a new key or paste a .pub anywhere. It shows up in Terminal on a Mac, and in git, scp, sftp, ssh-add, or a GUI client on that Mac. A Linux OpenSSH client prints the same lines. The file to change is the one named in the message.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'PATH' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
PATH is the file this client opened. The octal is that file’s mode. 0644 is the value people paste. OpenSSH refuses the private key because the current user owns it and a group or other permission bit is set. The key is ignored. It is not rewritten and it is not deleted. ssh may try another identity. ssh-add does not add that file. If none is accepted, the session often ends with Permission denied (publickey). That sentence has its own page.
Read the mode, then change that path. Quote the path when it contains spaces.
ls -l 'PATH'
ls -ld ~/.ssh
chmod 600 'PATH'
chmod 700 ~/.ssh
ls -l 'PATH'
After chmod 600, the private key line should show -rw-------. Retry the same ssh, ssh-add, git, scp, or sftp command. Do not start with a new key, chmod 777, or an attempt to ignore the warning.
These commands were not re-run on a Mac for this page. Flag meanings come from the manuals. The warning text comes from sshkey_perm_ok in OpenSSH authfile.c, as read for this page on 2026-11-19. The other OpenSSH links below are that same reading. Those links are the master tree at that reading. macOS ships its own build of OpenSSH. If man on the machine in front of you disagrees, that copy wins.
What this page is for
Match the @ banner, WARNING: UNPROTECTED PRIVATE KEY FILE, Permissions … are too open, and This private key will be ignored. Permissions 0644 for 'PATH' are too open and the shorter permissions 0644 are too open are this warning. ssh, ssh-add, scp, sftp, and git over SSH print it when an OpenSSH client reads a private key.
In the authfile.c read for this page, the function calls fstat on the open file descriptor and then tests:
if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
That branch prints the banner and returns SSH_ERR_KEY_BAD_PERMISSIONS. The octal in Permissions 0%3.3o for '%s' are too open. is st.st_mode & 0777. The comment above the test says a key owned by a different user does not get this particular check. This page stops at that comment. It does not tell you to use a key file owned by someone else.
ssh(1) FILES, as read on 2026-11-19, says the default private key files “contain sensitive data and should be readable by the user but not accessible by others (read/write/execute).” The same paragraph says ssh “will simply ignore a private key file if it is accessible by others.”
The words “permissions are too open” also appear in netplan. That program is outside this page.
GitHub’s Error: Permission denied (publickey), as fetched on 2026-11-19, has no section for UNPROTECTED PRIVATE KEY FILE. After this key is ignored, the session can still end on that sentence. GitHub’s page and the publickey note on this site explain that later sentence.
Some pastes name 0644 and suggest 0600 in a wording the OpenSSH files read for this page do not contain. The modes that pass the check above are 0600 and 0400.
What the warning means
sshkey_load_private_type calls sshkey_perm_ok and returns before sshkey_load_private_type_fd reads the key. A passphrase comes later, and only for a file this check has let through. The rows below are other layers.
| Text on screen | Read it as | Where to go |
|---|---|---|
WARNING: UNPROTECTED PRIVATE KEY FILE, Permissions … are too open, This private key will be ignored | This client ignored that private key file. | ls -l on the path in the message |
Permission denied (publickey) | The server refused the keys that were offered. | Permission denied (publickey) for git@github.com on a Mac |
Too many authentication failures | This connection offered too many keys. | Too many authentication failures |
ssh: connect to host … port 22: Connection refused | TCP. No key has been tried. | Connection refused, from a Mac or into a Mac |
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED | Host key. | REMOTE HOST IDENTIFICATION HAS CHANGED on Mac |
Bad configuration option: UseKeychain | Which ssh is on PATH. | UseKeychain on a Mac |
Bad owner or permissions on ~/.ssh/config | The client stops. A different test. | The section below |
A tunnel whose address and port kept changing is the Chinese incident 一次ssh排错经历.
In the sshconnect2.c read for this page, a failed load prints one more line and returns no key. error_r formats Load key "%s". ssherr.c maps SSH_ERR_KEY_BAD_PERMISSIONS to bad permissions. log.c appends that text after : . On the client’s stderr the line is:
Load key "PATH": bad permissions
With no public key loaded yet, userauth_pubkey does not send that identity and continues. With a public key already loaded, the log can show Offering public key before the private file is opened for the signature. identity_sign then returns SSH_ERR_KEY_NOT_FOUND, and sign_and_send_pubkey treats that as a soft failure. ssh-add.c calls sshkey_perm_ok and returns, so the banner is the whole ssh-add message. The file on disk stays as it was.
Read the path and the mode
ls -l the path inside the quotes. It can sit outside ~/.ssh. A .pem in Downloads or on the Desktop is a path this message can name. chmod 600 applies to that private key. chmod 700 applies to ~/.ssh. Leave Downloads and your home directory on their current mode.
0644 is -rw-r--r--: the owner can read and write, and group and others can read. The mask 077 is every group bit and every other bit, so a read-only bit is enough to fail. 0640 (-rw-r-----), 0660 (-rw-rw----), and 0777 (-rwxrwxrwx) fail the same test. 0600 is -rw-------. 0400 is -r--------. Both pass sshkey_perm_ok. Prefer chmod 600. chmod 400 also passes. It is not required.
How a private key ends up at 0644 is general guidance. Nothing here records one of these copies. A file saved into Desktop or Downloads, a copy out of a zip, a copy from a FAT or exFAT volume, a redirect under a typical umask of 022, or a checkout of a normal git file (mode 100644) can each land on 0644. The octal in the warning is the mode the check saw. This page does not describe iCloud, TCC, or FileVault.
The matching .pub is the public key. ssh(1) FILES says public key files “are not sensitive and can (but need not) be readable by anyone.” Chmod the private key named in the warning. The .pub may stay world-readable.
Change the mode, then retry
ls -l 'PATH'
ls -ld ~/.ssh
chmod 600 'PATH'
chmod 700 ~/.ssh
ls -l 'PATH'
Replace PATH with the path in the message. Confirm -rw-------, then run the same command that printed the warning. If the warning prints again, ls -l the path in the new message.
chmod 700 ~/.ssh follows ssh(1) FILES: recommended permissions for ~/.ssh/ are “read/write/execute for the user, and not accessible by others.” sshkey_perm_ok checks the key file. The directory line is that recommendation. If ls -ld ~/.ssh already shows drwx------, the directory is already there.
chmod 400 leaves -r--------. Use it when the owner should have read only. The usual line is chmod 600. Skip chmod 777 on the key, on ~/.ssh, on config, and on authorized_keys. Leave ~/.ssh in place, and leave the other keys in place.
When ls -l shows your login as the owner, chmod 600 is the change. The warning printed because st.st_uid == getuid() in the client that opened the file. When ls -l shows a different owner, that shell and the client are different accounts, or the owner changed after the warning. The source comment says a different owner does not get this check. This page does not add a message for a root-owned file. When ls clearly shows the wrong owner for the login that will run ssh, give the file back, then set the mode:
sudo chown USER 'PATH'
chmod 600 'PATH'
Replace USER with that login. Leave sudo off ssh and off git. sudo ssh reads root’s ~/.ssh. The publickey note already covers that split.
When the next line is Permission denied (publickey)
The ignored private key was not accepted by the server. ssh may already have tried other identities. Fingerprints, the keys on the GitHub account, and generating a key are Permission denied (publickey) for git@github.com on a Mac. This page does not run ssh-keygen and does not paste a .pub.
Bad owner or permissions on ~/.ssh/config
Bad owner or permissions on ~/.ssh/config is a different sentence. The same fatal is pasted with a home directory, authorized_keys, a path under /root or /home, or a WSL path. In readconf.c read_config_file_depth, when SSHCONF_CHECKPERM is set, the client calls fatal("Bad owner or permissions on %s", filename) and stops.
The test fires when the owner is neither root nor the current user, or when a group or other write bit is set (st.st_mode & 022). The private-key check fails on any group or other bit, including the read bits in 0644. A ~/.ssh/config at 0644 has no group or other write bit, so it can pass this config check when you or root own it. ssh(1) FILES says the file “must have strict permissions: read/write for the user, and not writable by others.” chmod 600 ~/.ssh/config is reasonable practice.
The publickey note already documents this fatal in its safety section, next to the warning against chmod 777. This section only separates the two sentences.
Windows and WSL
People paste this same English warning from Windows, from WSL, and from PowerShell. Inside WSL the files are on a Linux filesystem, and the walkthrough above is chmod plus ls -l. Windows ACL commands are outside this page. No current Microsoft or GitHub page of those steps is quoted here.
Where this page stops
- The commands were not re-run on a Mac for this page. No session on this site has this warning on screen. The manuals and the OpenSSH files linked above are the sources. The
manon the machine wins. - Search volume. This page does not add an external measurement.
- This page does not document a flag that tells the client to use an unprotected private key.
StrictModesis a server setting about the server user’s files and home directory. The publickey note already names it. Turning it off leaves this client-side check as it is.- Other people’s keys, and keys already stored on a GitHub account, stay where they are. The path in the message is the file this page changes.
- A
.pubfile may stay world-readable.
Other paths on the site start at Start Here. The Chinese writeup is WARNING: UNPROTECTED PRIVATE KEY FILE:Permissions are too open(Mac 上被忽略的 SSH 私钥).
If this post helps, you can sponsor the blog. This is voluntary personal support, not a charitable donation.