Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Using Netgroups

Netgroups are a great way to identify people and machines under nice, neat names for access control. A good example of using this feature is for a site where users are not allowed to log in to server machines. You can create a netgroup for the system administrators and let in members of the group through a special entry in the /etc/passwd file.

Netgroup information is kept in the /etc/netgroup file and shared via NIS.

The format of a netgroups file is as follows:


   groupname member-list

groupname is the name of the group being defined, and the member-list consists of other group names or tuples of specific data. Each entry in the member-list is separated by a whitespace.

A tuple containing specific data comes in this form:

(hostname, username, domain name)

hostname is the name of the machine for which that entry is valid, username is the login of the person being referenced, and domain name is the NIS domain name. Any entry left blank is considered a wildcard; for example, (technics,,,) implies everybody on the host technics. An entry with a dash in it (-) means that there are no valid values for that entry. For example, (-,sshah,) implies the user sshah and nothing else. This is useful for generating a list of users or machine names for use in other netgroups.

In files where netgroups are supported (such as /etc/passwd), you reference them by placing an @ sign in front of them. If you want to give the netgroup sysadmins consisting of (-,sshah,) (-,heidis,) permission to log in to a server, you add this line to your /etc/passwd file:

+@sysadmins

An example of a full netgroups file follows:

sysadmins    (-,sshah,) (-,heidis,) (-,jnguyen,) (-,mpham,)
servers      (numark,-,) (vestax,-,)
clients      (denon,-,) (technics,-,) (mtx,-,)
research-1   (-,boson,) (-,jyom,) (-,weals,) (-,jaffe,)
research-2   (-,sangeet,) (-,mona,) (-,paresh,) (-,manjari,) (-,jagdish,)
consultants  (-,arturo,)
allusers       sysadmins research-1 research-2 consultants
allhosts       servers clients

As a general rule, the line lengths should be no more than 1,024 characters. Although the system has no problems with the greater line lengths, it is difficult to edit the file because vi, view, and perhaps other editors have a 1,024-character line-length limitation.

Share ThisShare This

Informit Network