How to fix Bad owner or permissions on ~/.ssh/config in Git
SSH refuses to use your config file because it has insecure file permissions or is owned by another user. Fix by setting correct ownership and restricting permissions to owner-only read/write.
Quick fix
Fixes Bad owner or permissions on ~/.ssh/config
ls -la ~/.ssh/config
ls -ld ~/.ssh- Check current permissions and ownership
- Fix file permissions on Linux/macOS
- Fix file ownership if incorrect
- Fix permissions on Windows
ls -la ~/.ssh/configls -ld ~/.sshBad owner or permissions on ~/.ssh/config
What this error means
This error occurs when SSH (used by Git for secure connections) detects that your ~/.ssh/config file has permissions that are too open or is owned by someone other than you. SSH enforces strict security requirements on configuration files to prevent other users or processes from tampering with your SSH settings. The SSH client performs permission checks before reading configuration files. If the ~/.ssh/config file is world-readable, group-writable, or owned by root (when you're not root), SSH will refuse to use it. This protects you from malicious configuration that could redirect your connections or compromise your credentials. On Linux and macOS, the config file must be owned by your user and have permissions of 600 (read/write for owner only) or 400 (read-only for owner). On Windows, the file must only be accessible by SYSTEM and your user account.
Typical symptoms
- Git clone, fetch, or push commands fail when using SSH URLs
- SSH connections to Git hosting services (GitHub, GitLab, Bitbucket) fail with permission errors
- Error appears immediately when trying to establish SSH connection
- The same Git operations work with HTTPS URLs but fail with SSH
- Other SSH commands (not just Git) also fail with the same error
Common causes
- Config file permissions are too open (readable or writable by group or others)
- Config file is owned by root or another user instead of your account
- Copying files from another system preserved incorrect ownership
- Windows file inheritance settings allowed access to other users
- WSL home directory mapped to Windows home directory, bypassing Unix permissions
- File created by sudo or another elevated process
How to fix "Bad owner or permissions on ~/.ssh/config"
First, examine the current state of your SSH config file and directory:
ls -la ~/.ssh/config
ls -ld ~/.sshThe output should show:
- Owner: your username (not root)
- Permissions: -rw------- (600) for config file
- Directory permissions: drwx------ (700) for .ssh folder
Set the correct restrictive permissions on the config file:
chmod 600 ~/.ssh/configAlso ensure the .ssh directory itself has correct permissions:
chmod 700 ~/.sshThese commands set owner-only read/write access, which SSH requires.
If the file is owned by the wrong user, change ownership to your account:
chown $USER:$USER ~/.ssh/configTo fix ownership of the entire .ssh directory:
chown -R $USER:$USER ~/.sshYou may need to use sudo if the files are currently owned by root.
On Windows, you need to modify NTFS permissions:
1. Right-click on the .ssh folder in your user directory
2. Select "Properties" -> "Security" tab -> "Advanced"
3. Click "Disable inheritance" and choose "Convert inherited permissions"
4. Remove all users except SYSTEM and your user account
5. Check "Replace all child object permission entries..."
6. Click "Apply" and "OK"
For your user, ensure you have "Full control" permissions.
Test that SSH can now read your config file:
ssh -T git@github.comOr for GitLab:
ssh -T git@gitlab.comYou should see a welcome message instead of the permissions error.
Advanced notes
### WSL (Windows Subsystem for Linux) Considerations
If you are using WSL and have mapped your WSL home directory to your Windows home directory, chmod commands may have no effect because the Windows filesystem does not support Unix permissions natively.
Solutions:
1. Use WSL native home directory (recommended): Keep ~/.ssh inside the Linux filesystem (/home/username/.ssh)
2. Create a symlink: Store SSH files in the Linux filesystem and symlink from Windows if needed
3. Configure WSL metadata: Add to /etc/wsl.conf:
[automount]
options = "metadata,umask=022,fmask=011"### Multiple SSH Identities
If you use multiple SSH keys for different Git hosts, ensure your config file structure is correct:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github
Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519_gitlabEach referenced IdentityFile must also have 600 permissions.
Frequently asked questions
- What does "Bad owner or permissions on ~/.ssh/config" mean?
- ssh/config file has permissions that are too open or is owned by someone other than you. SSH enforces strict security requirements on configuration files to prevent other users or processes from tampering with your SSH settings. The SSH client performs permission checks before reading configuration files.
- How do I fix "Bad owner or permissions on ~/.ssh/config"?
- SSH refuses to use your config file because it has insecure file permissions or is owned by another user. Fix by setting correct ownership and restricting permissions to owner-only read/write.
- What causes "Bad owner or permissions on ~/.ssh/config"?
- Config file permissions are too open (readable or writable by group or others) Config file is owned by root or another user instead of your account Copying files from another system preserved incorrect ownership
- Is the "Bad owner or permissions on ~/.ssh/config" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Git Official Documentation
- ๐ฌ
- ๐ฌStack Overflow: bad owner or permissions on ssh config file(Stack Overflow)
- ๐ฌStack Overflow: openssh windows bad owner or permissions(Stack Overflow)