Centralized Authorization Using a Directory Service, Part II

Get a handle on administering who can log in where, with a proven, reliable centralized directory.

This defines the primary group IDs for jane to be 42 and for joe to be 57.

With the NIS group map you can add additional, secondary group memberships for accounts. The group entry:

projectX:*:127:jane,joe

defines a new group projectX with no password (*), group ID 127 and two members. No comments are allowed in the group file.

If you now set up a directory with read/write/execute permissions for group projectX:

# mkdir /projects/X/
# chgrp projectX /projects/X/
# chmod g+wrx /projects/X/

every member in the projectX group has permission to read/write/execute files inside that file space. The user might need to do a newgrp projectX first.

Whenever you need to add or remove accounts to or from the group map, do it on your NIS master server by editing the /etc/NIS/group file and executing the commands:

% cd /var/yp
% sudo make group

These generate a new group map that makes the changes visible instantaneously on all clients. There is no need to touch any client to make these changes. Everything now is centralized in one place on your NIS master server.

NIS Netgroups

Netgroups are very different from groups. Netgroups come in two flavors, user netgroups and host netgroups. Both types of netgroups can contain netgroups as members, so netgroup definitions can be hierarchical. Both types of netgroups are defined in the same netgroup file. Comments are allowed in the netgroup file.

Host netgroup definitions in /etc/NIS/netgroup look like this:

# Group of project groups:
projects \
      projectA \
      projectB \
      projectX

# Group of hosts for Project X
projectX \
        (host1.example.com,-,) \
        (host2.example.com,-,) \
        (host3.example.com,-,)

These host netgroup definitions now allow you to, for example, export NFS space only to subsets of your machines. In your NFS server's /etc/exports file, you can use constructs like these:

# export the /projects directory to all machines
# in the "projects" netgroup
/projects    @projects(rw,root_squash)

# export Project X' space only to machines
# in the "projectX" netgroup
/projects/X           @projectX(rw,root_squash)

Again, adding or removing hosts or adding/deleting netgroups is a simple edit of the /etc/NIS/netgroup file on your NIS master server. Execute cd /var/yp; sudo make netgroup to update the NIS map, and the changes are visible everywhere instantly.

User Netgroups

User netgroups, which are netgroups with accounts as members, typically are used to restrict login to computers. User netgroup definitions look slightly different from host netgroup definitions:

# Group of project user groups
u-projects \
        u-projectA \
        u-projectB \
        u-projectX

# Group of users in Project X
u-projectX \
        (-,jane,) \
        (-,joe,) \
        (-,nick,)

The prefix u- in the names is a convention to distinguish user netgroups from host netgroups.

With these definitions in place, you now can grant or restrict login access to your computers with these kinds of entries in a machine's local /etc/passwd file. Remove a + at the very end of the passwd files if present:

  • Allow access for all accounts in the u-projects netgroup and no one else:

    +@u-projects
    

  • Allow access for only the u-projectX netgroup members and no one else:

    +@u-projectX
    

  • Allow access to everybody in u-projects but not in u-projectX:

    -@u-projectX
    +@u-projects
    

    Order here is important. The first match determines what happens.

  • Allow everybody in u-projectA and also account nick

    +@u-projectA
    +nick
    

The information about nick (home directory, login shell and so on) comes out of the NIS passwd map. It is better to avoid putting explicit account names in here, because management of these entries is not centralized.

To make this +/- syntax work, your clients need to have the entry

passwd:         compat

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Part I Please

shann's picture

can you post the link for the Part I of this article?

thanks & regards
shann
massoo@30gigs.com
massoo@gmail.com

Links

Pasamio's picture

Central Authentication with Kerberos 5
http://www.linuxjournal.com/article/7336 (Part I)

Centralized Authorization Using a Directory Service
http://www.linuxjournal.com/article/7334 (Part II)

AFS - A Secure Distributed Filesystem
http://www.linuxjournal.com/article/7521 (Part III)

Was a bit confusing since the article titles are all different.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix