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 user@myserver.com it was trying to use that id_rsa without questioning me the password. Avoid the global IdentityFile and it will all go well. – giovannipds Oct 3 '19 at 19:12

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
  • 25
    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 '15 at 12:27
  • 7
    In my case, going from 644 to 600 did the trick. – Magicsowon Oct 18 '16 at 18:15
  • 2
    Just read permission should be sufficient, i.e. 400 – 030 Jan 2 '17 at 0:06
  • 1
    For me, 600 didn't work, only 400 (on Ubuntu Xenial) – Martín Coll Oct 25 '17 at 0:35
  • 1
    To my surprise, 660 is considered "Bad owner or permissions on ~/.ssh/config" but 600 isn't. Thanks! – HCSF Jul 4 '19 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.

  • 4
    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. – Damodar Bashyal Apr 27 '16 at 5:54
  • This worked for me. – Viraj Wadate May 25 '19 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. – kiamlaluno May 29 '20 at 18:46
  • Yep, I find myself coming back to this answer every now and then :-) – ArchNoob Dec 2 '20 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 '19 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. – Piotr P. Karwasz Jan 13 '20 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. – Alexander Gavriliuk Jan 14 '20 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.


  • This doesn't help if I need the contents of the config file to be used when logging into a remote ssh host – shonky linux user Sep 1 '20 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 – Rohit Salecha Jan 11 at 12:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.