I'm trying to use ssh.exe in Cygwin (in Windows 7). I copied a config file into c:\cygwin\home\[USERNAME]\.ssh. When I run ssh (for example, ssh -vT [email protected]) I get the following error:

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011 Bad owner or permissions on /home/[USERNAME]/.ssh/config

How do I get ssh to read my configuration file?

  • This issue can be repro if you move a cygwin folder from a Windows installatino to another. Especially tricky when you reinstall a computer and the computer name\username is the same to detect.
    – Dereckson
    Jun 12, 2020 at 15:06

8 Answers 8


After doing as above, I always got this:

total 22
drwxrwxr-x+ 1 jl None    0 Sep  9 18:44 .
drwxrwxr-x+ 1 jl None    0 Sep  9 18:44 ..
-rw-rw----  1 jl None  129 Jul  1 14:30 config

and the error on .ssh/config. So I've run chown on the .ssh folder, and chmod again like this:

> chown -R [USERNAME]:users .ssh/

and then:

> chmod -R 600 .ssh/

and finally I got it working:

total 29
drwxrwxr-x+ 1 jl None     0 Sep  9 18:44 .
drwxrwxrwt+ 1 jl None     0 Sep  9 18:44 ..
drw-------+ 1 jl Users    0 Sep  9 18:44 .ssh

Edit(for bash on Windows10)

When you get the error..

Failed to add the host to the list of known hosts (/PATH_TO_HOME/USERNAME/.ssh/known_hosts).

Make sure that known_hosts is writable

$ chmod 755 known_hosts

Note: I believe you only need to set 600 for your private key

Then, try to ssh.

When you get..

Permanently added 'HOST_IP' (RSA) to the list of known hosts.

You may replace mode 600

$ chmod 600 known_hosts

P.S.: I think this is a bug on Windows 8.

  • The accepted answer didn't work for me, but this did. Thanks!
    – Achal Dave
    Sep 12, 2013 at 3:54
  • Also, this is quite a weird bug. On my computer (W8.1), editing the .ssh/config file in Vim always leads to this bug. It's extremely annoying, as every change to my ssh config requires running these commands.
    – Achal Dave
    Oct 22, 2013 at 18:14
  • 4
    And just to add to the weirdness, if you're using an non English version of Windows then make sure to use the locale translation of "users" when issuing this command. For example in Dutch it becomes "chown -R :Gebruikers .ssh" Jan 13, 2014 at 10:27
  • 1
    For me, this worked: chown -R m0j0:Users .ssh && chmod -R go-rwx .ssh
    – m0j0
    Jan 23, 2014 at 14:40
  • 1
    Thanks this worked for me as well, in German you need to use chown -R [Username]:Benutzer .ssh/
    – con
    Sep 8, 2014 at 17:23

This answer is copied verbatim from https://superuser.com/a/875934/82032. This is the only answer that worked for me after a recent cygwin upgrade.

Don't forget the ACLs

Nothing worked for me until I stripped the file of ACLs and reset the permissions.

#remove ACLs
setfacl -b ~/.ssh/config

#reset permissions
chmod 0600 ~/.ssh/config

You can use getfacl to view the current ACL on a file.

getfacl ~/.ssh/config

Before I removed the ACLs (Broken):

# owner: Administrators
# group: None
group:Authenticated Users:rwx

After: (working)

# file: config
# owner: myusername
# group: None
  • This is what I had to do after upgrading cygwin
    – blockloop
    Feb 20, 2015 at 17:01
  • 1
    This requires cygwin 1.7.34-6
    – ClintM
    Feb 20, 2015 at 22:18
  • This is what worked for me! Mar 3, 2015 at 15:45

For unix & OSX

Quite simply:

chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/

For Windows

If the file is a windows (NTFS) symbolic link, the above won't work. You need to make it a regular file. I am not sure why.

If you don't have openssh or cygwin, use chocolatey to install it easily.

choco install cyg-get

Open Cygwin Terminal that was installed with chocolatey and run (note that ssh-keygen creates new keys):

cyg-get install openssh
cd ~/.ssh && explorer.exe .

Verify keys are there (or replace them with the keys you want), and then in Cygwin shell:

chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/

Or for the rare case that you're using (and generated the keys from) chocolatey's SSH package:

chown -R $USER:users  /cygdrive/c/Users/$USER/.ssh
chmod -R 600 /cygdrive/c/Users/$USER/.ssh
  • This is usually it for me, since the group is usually wrong on the files. Jan 4, 2015 at 2:56

Check the permissions of the config file using Cygwin's ls command:

> c:\cygwin\bin\ls.exe -la c:\cygwin\home\[USERNAME]\.ssh

It will probably be something like this:

total 5
drwxrwxrwt+ 1 Administrators None  0 Oct 20 17:02 .
drwxr-xr-x+ 1 [USERNAME]     None  0 Oct 19 08:15 ..
-rw-------  1 Administrators None 57 Oct 20 16:58 config

The config file needs to belong to [USERNAME]. Try this:

> c:\cygwin\bin\chown.exe [USERNAME] c:\cygwin\home\[USERNAME]\.ssh\config

ls -la should now show the correct owner. If that still doesn't work, try resetting the mode (permissions):

> c:\cygwin\bin\chmod.exe 700 c:\cygwin\home\[USERNAME]\.ssh\config

Important note if your Windows is not in US English: the "users" group's name is locale-dependant. For example, if your Windows is in Spanish, you'll have to change the files' ownership with chown $USER:Usuarios *


None of these (chmod/chown/icacls/setacl/copyacls/explorer>security) worked on my cygwin64/win7/admin, finally this works with cygwin64/ssh -F ~/.ssh/config other solutions are to use older ssh in cygwin32 or ssh in git for windows..

  • Using -F will solve the problem with config, but won't solve permissions for private keys. Oct 30, 2018 at 17:03

For those who uses noacl in path with ~/.ssh dir simple solution is to create native NTFS symbolic link:

cmd# mklink c:\home\.ssh c:\opt\cygwin\home\misc\.ssh
symbolic link created for c:\home\.ssh <<===>> c:\opt\cygwin\home\misc\.ssh

With noacl there is no way to set permissions other then rwxr-xr-x or rw-r--r--. As / hierarchy should be without noacl (or should be with acl) you can create directory here and point to it problematic places for Cygwin's apps.

  • 1
    Given this is a directory, the simple solution would be using a junction, because that doesn't require the privileges required for setting a symbolic link. That'd be mklink /j then or the junction tool from the Sysinternals Suite. Mar 22, 2018 at 9:47

tldr: You may have created the config as adminstrator


These solutions may be overkill if you ended up mistakenly creating the file as admin, and trying to use the file with local perms.

  • Copy the contents of your ssh config
  • Delete the file
  • Open a new shell (local - non admin)
  • Navigate to the path where your config is stored (usually ~/.ssh in PowerShell or %userprofile%\.ssh in cmd)
  • Run notepad .\config

Simple commands (PowerShell):

$sshPath = '~/.ssh/config'
$content = cat $sshPath
# In case the line above fails, this check will prevent your current config to get deleted
if ($content) {
  rm $sshPath
  $content | Out-File -en ascii $sshPath

You must log in to answer this question.

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