Skip to content

Instantly share code, notes, and snippets.

@tosiara
Created December 29, 2021 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosiara/9e926e1ce1c91a815be0f6d8573c876e to your computer and use it in GitHub Desktop.
Save tosiara/9e926e1ce1c91a815be0f6d8573c876e to your computer and use it in GitHub Desktop.
Patch for sshd: Authentication refused: bad ownership or modes for directory /data

You may not connect to sshd on LineageOS because of wrong /data permissions:

sshd: Authentication refused: bad ownership or modes for directory /data
  1. Navigate to your LineageOS 14.1 source dir
  2. Open file external/openssh/misc.c
  3. Find function safe_path and comment out this code block:
                /*
                if (stat(buf, &st) < 0 ||
                    (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) ||
                    (st.st_mode & 022) != 0) {
                        snprintf(err, errlen,
                            "bad ownership or modes for directory %s", buf);
                        return -1;
                }
                */
    
  1. Rebuild

Already fixed in the latest version using ifdef statments:

https://github.com/LineageOS/android_external_openssh/blob/lineage-18.1/misc.c#L1929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment