How to fix Bad owner or permissions on ~/.ssh/config in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025ยท 271 views

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
  1. Check current permissions and ownership
  2. Fix file permissions on Linux/macOS
  3. Fix file ownership if incorrect
  4. Fix permissions on Windows
git โ€” error
ls -la ~/.ssh/config
ls -ld ~/.ssh
Bad 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

  1. Config file permissions are too open (readable or writable by group or others)
  2. Config file is owned by root or another user instead of your account
  3. Copying files from another system preserved incorrect ownership
  4. Windows file inheritance settings allowed access to other users
  5. WSL home directory mapped to Windows home directory, bypassing Unix permissions
  6. File created by sudo or another elevated process

How to fix "Bad owner or permissions on ~/.ssh/config"

1Check current permissions and ownership

First, examine the current state of your SSH config file and directory:

bash
ls -la ~/.ssh/config
ls -ld ~/.ssh

The output should show:
- Owner: your username (not root)
- Permissions: -rw------- (600) for config file
- Directory permissions: drwx------ (700) for .ssh folder

2Fix file permissions on Linux/macOS

Set the correct restrictive permissions on the config file:

bash
chmod 600 ~/.ssh/config

Also ensure the .ssh directory itself has correct permissions:

bash
chmod 700 ~/.ssh

These commands set owner-only read/write access, which SSH requires.

3Fix file ownership if incorrect

If the file is owned by the wrong user, change ownership to your account:

bash
chown $USER:$USER ~/.ssh/config

To fix ownership of the entire .ssh directory:

bash
chown -R $USER:$USER ~/.ssh

You may need to use sudo if the files are currently owned by root.

4Fix permissions on Windows

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.

5Verify the fix

Test that SSH can now read your config file:

bash
ssh -T git@github.com

Or for GitLab:

bash
ssh -T git@gitlab.com

You 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:

ini
[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:

bash
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_gitlab

Each 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