Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

Last login: sometime from somewhere
user.x@srv:~$ groups
user.x
user.x@srv:~$ groups user.x
user.x : user.x grp1 grp2
user.x@srv:~$ su - user.x
Password:
user.x@srv:~$ groups
user.x grp1 grp2
user.x@srv:~$ exit
user.x@srv:~$ groups
user.x

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
share|improve this question
    
What is the situation when you log in and then run /bin/bash --login instead of su -? –  rozcietrzewiacz Aug 29 '11 at 15:36
    
@rozcietrzewiacz Then the group information is invalid too. The same holds true for /bin/dash -l –  dtech Aug 29 '11 at 16:23
    
This looks like some broken configuration then, probably something in /etc/profile - see my answer. –  rozcietrzewiacz Aug 29 '11 at 16:34
add comment

3 Answers

up vote 1 down vote accepted

The problem was that the group information was first pulled from nis and then from the local copies of the nis (made by ypserv)

The solution was changing /etc/nsswitch.conf from

group: compat

to:

group: files nis compat
share|improve this answer
add comment

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).

share|improve this answer
add comment

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.

share|improve this answer
    
The groups were created long before this particular SSH session was started. The commands are literately run after logging in. –  dtech Aug 29 '11 at 16:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.