Groups differ from the local ones when logging in remotely

I took heart today and finally solved it. The pam chain works like this

  • /etc/pam.d/sshd includes:
    • /etc/pam.d/system-remote-login that includes:
      • /etc/pam.d/system-login that includes:
        • /etc/pam.d/system-auth which has an optional requirement

Apparently the last include does not work for some reason. The reason why I was so puzzled so far was that I trusted that these includes would work, which wasn't the case. If someone can explain why I'd be very grateful. I know this because if i add the line

auth    optional  pam_group.so

into the /etc/pam.d/system-login then it works.