5

I'm attempting to setup Git with OpenSSH under Cygwin. I almost got everything setup. I have the agent and public key and all that.. but now I get this really weird error:

$ git pull -u origin master
Bad owner or permissions on /home/Jordan/.ssh/config
fatal: The remote end hung up unexpectedly

Googling it appears to be a permissions error(of course). One problem: the permissions look fine to me.

I've also tried doing a chmod 0600 ~/.ssh/config, but that didn't help. What I've tried doing:

Jordan@EarlzWindows8VM ~/dev/NonExceptional
$ chmod 0600 ~/.ssh/config 

Jordan@EarlzWindows8VM ~/dev/NonExceptional
$ stat ~/.ssh/config 
  File: `/home/Jordan/.ssh/config'
  Size: 47              Blocks: 1          IO Block: 65536  regular file
Device: 4ade2efdh/1256075005d   Inode: 1970324837237461  Links: 1
Access: (0660/-rw-rw----)  Uid: ( 1001/  Jordan)   Gid: (  513/    None)
Access: 2013-01-12 22:53:32.483072600 -0500
Modify: 2013-01-12 22:53:32.486074700 -0500
Change: 2013-01-12 23:27:33.077476800 -0500
 Birth: 2013-01-12 22:53:32.483072600 -0500

Notice that for whatever reason, the permissions still appear to be 0660. I don't understand why though. I've verified these permissions in Windows Explorer. Only I have access to the file, and when checking the "effective access", the group Users does not have access to the file.

How do I fix this error?

Also, some background: Windows 8 Enterprise. Joined to a domain(which always makes permissions fun). Cygwin is up to date

Earlz
  • 4,564

8 Answers8

16

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:---
AndrewD
  • 512
6

Iv'e found that this always fixes it:

chown Username:Users ~/.ssh/config
chmod go-rw ~/.ssh/config
4

The problem ended up being that the file was owned by group "None". I changed the group to "Users" and then I could freely change the permissions

I figured this out from this related question

Earlz
  • 4,564
2

This solution helped me:

cd ~/.ssh
chmod 600 *
milkovsky
  • 211
  • 2
  • 6
1

My cygwin64 on win7 running as admin, the chmod/chown/setacl/icacls/copyacls/ didn't help; only this worked: ssh -F ~/.ssh/config ...

mosh
  • 317
0

This one worked for windows from the windows file properties 'Owner' tab add required USER as owner cd to the location where config file present then ssh to host

0

These commands should work:

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

Prefix with sudo if the files are owned by different user.

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.

kenorb
  • 26,615
-2

Your configuration file is writable for the group, and SSH doesn't like that. Do a

chmod go-rw ~/.ssh/config

vonbrand
  • 2,509