I have a problem on a server I manage. An account (specifically, my account) does not seem to have the correct groups. I think the problem is most easily demonstrated by looking at the following command sequence:

So the problem is that the groups for user.x are incorrectly reported after logging in (through SSH). If logging in is simulated again (su -) or the username is supplied with the groups or id command it works fine.

The incorrect groups cause all sorts of problems, like not being able to sudo. How can I fix this?

Further information that might be relevant:

The server is a NIS client which synchronises every 15 minutes

The problem is rare, but not unique, at the moment 2 users have acquired it in the last half-year

The problem seems to only happen to users that SSH into the machine often

Group permissions are set at the time the shell is created. The very first shell where groups output only shows user.x, was that shell created before adding the other groups? If so simply log out and log in again.

It looks like a problem with the user shells' configurations. Check how the shells are defined in /etc/passwd and inspect the /etc/profile, users' login scripts (like .bashrc, .bash_login, .profile etc.) for any errors. If you don't find anything that would fix it, backup those files and restore default ones. Possibly re-install the shell(s).