When I try to ssh to another box, I get this strange error

$ ssh hostname
Bad owner or permissions on ~/.ssh/config

But I made sure that I own and have rw permissions on the file:

ls -la ~/.ssh/
total 40K
drwx------ 2 robert robert 4.0K Mar 29 11:04 ./
drwx------ 7 robert robert 4.0K Mar 29 11:04 ../
-rw-r--r-- 1 robert robert 2.0K Mar 17 20:47 authorized_keys
-rw-rw-r-- 1 robert robert   31 Mar 29 11:04 config
-rw------- 1 robert robert 1.7K Aug  4  2010 id_rsa
-rw-r--r-- 1 robert robert  406 Aug  4  2010 id_rsa.pub
-rw-r--r-- 1 robert robert 6.1K Mar 29 11:03 known_hosts
  • I just had the same message. My case was different. I was having a global IdentityFile ~/.ssh/id_rsa set, so when I was trying to access [email protected] it was trying to use that id_rsa without questioning me the password. Avoid the global IdentityFile and it will all go well. Oct 3, 2019 at 19:12
  • This happened to me on macOS after installing SourceTree - I opened up the config file and found there was nothing useful in it, just generated code by SourceTree, which I no longer use anyway. Removing the file (renaming it to config.bak) solved my issue! Apr 18, 2022 at 14:04

6 Answers 6


I needed to have rw for user only permissions on config. This fixed it.

chmod 600 ~/.ssh/config

As others have noted below, it could be the file owner. (upvote them!)

chown $USER ~/.ssh/config

If your whole folder has invalid permissions here's a table of possible permissions:

Path Permission
.ssh directory (code) 0700 (drwx------)
private keys (ex: id_rsa) (code) 0600 (-rw-------)
config 0600 (-rw-------)
public keys (*.pub ex: id_rsa.pub) 0644 (-rw-r--r--)
authorized_keys (code) 0644 (-rw-r--r--)
known_hosts 0644 (-rw-r--r--)


  • 31
    Sometimes it's not only the permissions, but also the owner that can cause the problem; in my case, I had to do this as well: chown -R robert:robert ~/.ssh
    – Nicolas C
    Jan 26, 2015 at 12:27
  • 10
    In my case, going from 644 to 600 did the trick. Oct 18, 2016 at 18:15
  • 5
    Just read permission should be sufficient, i.e. 400
    – 030
    Jan 2, 2017 at 0:06
  • 3
    For me, 600 didn't work, only 400 (on Ubuntu Xenial) Oct 25, 2017 at 0:35
  • 2
    To my surprise, 660 is considered "Bad owner or permissions on ~/.ssh/config" but 600 isn't. Thanks!
    – HCSF
    Jul 4, 2019 at 3:47

These commands should fix the permission problem:

chown $USER ~/.ssh/config
chmod 644 ~/.ssh/config

Prefix with sudo if the files are owned by different user (or you don't have access to them).

If more files are affected, replace config with *.

In man ssh we can read:

Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not writable by others. It may be group-writable provided that the group in question contains only the user.

  • 5
    This did the trick for me. I am using cygwin and cygwin .ssh is symlinked to windows user .ssh. I had to run those commands in cygwin window. Apr 27, 2016 at 5:54
  • This worked for me. May 25, 2019 at 7:17
  • This worked for me. chown was not necessary, since the file was already owned from the right account. I was not understanding how the permissions could be wrong, until I read this answer.
    – apaderno
    May 29, 2020 at 18:46
  • Yep, I find myself coming back to this answer every now and then :-)
    – ArchNoob
    Dec 2, 2020 at 10:04

For me it was an issue with my user account not being the owner of the file

sudo chown myuser ~/.ssh/config

If on Windows Subsystem for Linux (WSL) and you pointed your WSL home directory to your Windows home directory (not recommended!) then chmod has no effect. Before you can chmod the files mentioned in other answers you must add

options = "metadata"

to your /etc/wsl.conf then restart WSL (requires build 17093 or later).

Before mount says:

C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off)

After mount says:

C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,metadata,case=off)
  • 3
    I'm on Windows 10 Version 1903 and chmod in WSL just worked.
    – ahofmann
    Oct 23, 2019 at 15:05

Don't forget about the group:

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


  • The group does not matter if the file is not group writable. If it is, the group must at most contain the user. Jan 13, 2020 at 23:23
  • I just thought that if this file unexpectedly has a wrong user, it also can have a wrong group. To make all things right we'd better take an attention on the group too. Jan 14, 2020 at 13:24

I met this issue on windows 10 with vagrant ssh. And tried all the above methods, but get no luck. Finally I deleted that ssh config file and then it works!

vagrant ssh
Bad owner or permissions on C:\\Users\\Jeff/.ssh/config
del ..\.ssh\config

vagrant ssh
Welcome to Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-170-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu Feb 27 02:23:03 UTC 2020

  System load:  0.0               Processes:              77
  Usage of /:   5.1% of 39.34GB   Users logged in:        0
  Memory usage: 21%               IP address for eth0:
  Swap usage:   0%                IP address for docker0:

  Graph this data and manage this system at:

New release '16.04.6 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


  • 1
    This doesn't help if I need the contents of the config file to be used when logging into a remote ssh host Sep 1, 2020 at 1:18
  • this worked for me same issues vagrant ssh was not working created a backup of the config file and then tried vagrant ssh and it worked. Thanks Jan 11, 2021 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .