cygsshd fails due to bad ownership or modes of /cygdrive/c/Users

Frank-Ulrich Sommer f-u.s@gmx.net
Tue Feb 6 01:28:41 GMT 2024


Looking at the OpenSSH source code (on Github, not from Cygwin) I found a function "safe_path" that checks that the ownership and access modes for all path components are correct.  This relies on "platform_sys_dir_uid" which checks if a UID may own a system directory. The code checks for UID zero and might also accept an OS specific second value (PLATFORM_SYS_DIR_UID) but for Cygwin this seems not to be set. But I don't know where to find the source code for the excat version that is used in Cygwin and I'm unsure about build settings.

A comment defines this a safe path as follows:
"This is defined as all components of the path to the file must be owned by either the owner of the file or root and no directories must be group or world writable."

The "Users" directory is owned by "SYSTEM" (numeric: 18 according to stat) and only writable by Administrators and SYSTEM. The mode cygwin shows for /cygdrive/c/Users is 0750 which should be OK.

So my question is: are "Administrators" and "SYSTEM" different users and does cygsshd accept SYSTEM (numeric 18) as a valid user who may own system directories? If the numeric ID is really 18 I can't see how this check can succeed but I'm not sure the code used in Cygwin is the same.

On 05.02.2024 00:53, Frank-Ulrich Sommer via Cygwin wrote:
> Hi,
>
> I'm trying to run cygsshd on my PC with Windows 11 and connect from a linux machine. I have added the public key to /cygdrive/c/Users/xxx/.ssh/authorized_keys and created a symbolic link from  /cygdrive/c/Users/xxx/.ssh to /home/xxx/.ssh. As usual I checked the access rights and mode of the .ssh directory (700 and belongs to user xxx) and the authorized_keys file (600 and also belongs to user xxx) and also of the home directory (had to change ownership).
>
> Now I get the following strange messages:
>
> [...]
> Feb  5 00:35:50 XXXXX sshd: PID 2798: debug1: temporarily_use_uid: 197609/197121 (e=18/18)
> Feb  5 00:35:50 XXXXX sshd: PID 2798: debug1: trying public key file /home/xxx/.ssh/authorized_keys
> Feb  5 00:35:50 XXXXX sshd: PID 2798: debug1: fd 5 clearing O_NONBLOCK
> Feb  5 00:35:50 XXXXX sshd: PID 2798: Authentication refused: bad ownership or modes for directory /cygdrive/c/Users
> Feb  5 00:35:50 XXXXX sshd: PID 2798: debug1: restore_uid: 18/18
> [...]
>
> Why is cygsshd complaining about the Windows "Users" directory and not about the directory of user xxx (/cygdrive/c/Users/xxx)? And how can I solve this?
>
> Frank
>



More information about the Cygwin mailing list