Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 git@bitbucket.org) 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?

share|improve this question

5 Answers 5

This answer is copied verbatim from http://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
user::rw-
group::---
group:Authenticated Users:rwx
group:SYSTEM:rwx
mask:rwx
other:---

After: (working)

# file: config
# owner: myusername
# group: None
user::rw-
group::---
other:---
share|improve this answer
    
This is what I had to do after upgrading cygwin –  brettof86 Feb 20 at 17:01
    
This requires cygwin 1.7.34-6 –  ClintM Feb 20 at 22:18
    
This is what worked for me! –  Ashutosh Jindal yesterday

Quite simply:

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

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.

Or if you have them in your default Windows Users directory:

chown -R $USER:users /cygdrive/c/Users/$USER/.ssh/
chmod -R 600 /cygdrive/c/Users/$USER/.ssh/

And if you are using choco and "OpenSSH for Windows" (choco install openssh) just abondon it and do this instead, run these commands:

choco install cygwin

Open Cygwin shell and run (note that ssh-keygen creates new keys):

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin    
apt-cyg install wget openssh
ssh-keygen
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/
share|improve this answer
    
This is usually it for me, since the group is usually wrong on the files. –  Alan Krueger Jan 4 at 2:56

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

share|improve this answer

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

ps: i think this is a bug on Windows 8

share|improve this answer
    
The accepted answer didn't work for me, but this did. Thanks! –  Achal Dave Sep 12 '13 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 '13 at 18:14
3  
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" –  Alexander Kellett Jan 13 '14 at 10:27
1  
For me, this worked: chown -R m0j0:Users .ssh && chmod -R go-rwx .ssh –  m0j0 Jan 23 '14 at 14:40
    
Tried changing the group on just .ssh/config, but it didn't work until I first changed the group on the .ssh directory itself. Thanks! –  Paul Brannan Mar 27 '14 at 16:20
up vote 5 down vote accepted

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
share|improve this answer
1  
Great answer. Seems it is very particular about the combination, I gave it greater access than that and it wasn't working. –  Matthew Read Sep 20 '12 at 17:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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