[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Network Information Services (NIS and NIS+) Guide

Administering NIS+ Credentials

This section assumes that you have an adequate understanding of the NIS+ security system in general, and in particular of the role that credentials play in that system (see the Security chapter for this information)

This section provides the following general information about credentials.

This section then describes how to use the NIS+ credential administration commands to perform the following tasks.

How Credentials Work

This section describes how the credential and authentication process works.

The credential/authentication system prevents someone from assuming some other user's identity. That is, it prevents someone with root privileges on one machine from using the su command to assume the identity of a second user who is either not logged in at all or logged in on another machine and then accessing NIS+ objects with the second user's NIS+ access privileges.

Note: NIS+ cannot prevent someone who knows another user's login password from assuming that other user's identity and the other user's NIS+ access privileges, nor can NIS+ prevent a user with root privileges from assuming the identity of another user who is currently logged in on the same machine.

See Security for a description of how NIS+ credentials and authentication work with authorization and access rights to provide security for the NIS+ namespace.

Credential versus Credential Information

To understand how DES credentials are created and how they work, you need to distinguish between the credential itself and the information that is used to create and verify it.

Authentication Components

For the credential/authentication process to work, the following components must be in place:

How Principals are Authenticated

There are three phases to the authorization process:

These three phases are described in detail in the following subsections.

Credentials Preparation Phase

Prior to an NIS+ principal logging in, an NIS+ administrator must create DES credential information for that principal (user or machine). (The easiest way for an NIS+ adminstrator to create credential information for users is to use the nisclient script as described in the nisclient command description.) The administrator must:

Login Phase -- Detailed Description

When a principal logs into the system the following steps are automatically performed:

  1. The keylogin program is run for the principal. The keylogin program gets the principal's encrypted private key from the cred table and decrypts it using the principal's login password.
    Attention: When a principal's login password is different from his or her Secure RPC password, keylogin cannot decrypt it and the user starts getting "cannot decrypt" errors or the command fails without a message. For a discussion of this problem, see Secure RPC Password versus Login Password Problem.
  2. The principal's decrypted private key is passed to the keyserver which stores it for use during the request phase.
    Note: The decrypted private key remains stored for use by the keyserver until the user does an explicit keylogout. If the user simply logs out (or goes home for the day without logging out), the decrypted private key remains stored in the server. If someone with root privileges on a user's machine switched to the user's login ID, that person would then have use of the user's decrypted private key and could access NIS+ objects using the user's access authorization. Thus, for added security, users should be cautioned to perform an explicit keylogout when they cease work. If they also log out of the system, all they need do is log back in when they return.
Request Phase -- Detailed Description

Every time a NIS+ principal requests access to an NIS+ object, the NIS+ software performs a multistep process to authenticate that principal:

  1. NIS+ checks the cred table of the object's domain. If:

    NIS+ gets the user's DES credential from the cred table of the user's home domain. The encrypted private key is decrypted with the user's password and saved by the keyserver.

  2. NIS+ obtains the server's public key from the NIS+ directory object.
  3. The keyserver takes the principal's decrypted private key and the public key of the object's server (the server where the object is stored) and uses them to create a common key.
  4. The common key is then used to generate an encrypted DES key. To do this, Secure RPC generates a random number which is then encrypted using the common key. For this reason, the DES key is sometimes referred to as the random key or the random DES key.
  5. NIS+ then takes the current time of the principal's server and creates a time stamp that is encrypted using the DES key.
  6. NIS+ then creates a 15-second window, which is encrypted with the DES key. This window is the maximum amount of time that is permitted between the time stamp and the server's internal clock.
  7. NIS+ then forms the principal's DES credential, which is composed of the following:
  8. NIS+ then passes the following information to the server where the NIS+ object is stored:
  9. The object's server receives this information.
  10. The object's server uses the Secure RPC netname portion of the credential to look up the principal's public key in the cred table of the principal's home domain.
  11. The server then uses the principal's public key and the server's private key to regenerate the common key. This common key must match the common key that was generated by the principal's private key and the server's public key.
  12. The common key is used to decrypt the DES key that arrived as part of the principal's credential.
  13. The server decrypts the principal's time stamp with the newly decrypted DES key and verifies it with the window verifier.
  14. The server then compares the decrypted and verified time stamp with the server's current time and proceeds as follows:
    1. If the time difference at the server exceeds the window limit, the request is denied and the process aborts with an error message. For example, suppose the time stamp is 9:00am and the window is one minute. If the request is received and decrypted by the server after 9:01am, it is denied.

      If the time stamp is within the window limit, the server checks to see if the time stamp is greater than the one previously received from the principal. This ensures that NIS+ requests are handled in the correct order.

    2. Requests received out of order are rejected with an error message. For example, if the time stamp is 9:00am and the most recently received request from this principal had a time stamp of 9:02am, the request would be rejected.

      Requests that have a time stamp equal to the previous one are rejected with an error message. This ensures that a replayed request is not acted on twice. For example, if the time stamp is 9:00am and the most recently received request from this principal also had a time stamp of 9:00am, this request would be rejected.

      If the time stamp is within the window limit, and greater than the previous request from that principal, the server accepts the request.

  15. The server then complies with the request and stores the time stamp from this principal as the most recently received and acted on request.
  16. To confirm to the principal that the information received from the server in answer to the request comes from a trusted server, the server encrypts the time stamp with the principal's DES key and sends it back to the principal along with the data.
  17. At the principal's end, the returned time stamp is decrypted with the principal's DES key.

The DES Credential in Detail

The DES credential consists of:

DES Credential Secure RPC Netname

This portion of the credential is used to identify the NIS+ principal. (Remember that an NIS+ principal name always has a trailing dot, while a Secure RPC netname never does.) Every Secure RPC netname contains three components:

Prefix
The prefix is always the word unix.
Identifier
If the principal is a client user, the ID field is the user's UID. If the principal is a client workstation, the ID field is the workstation's hostname.
Domain name
The domain name is the name of the domain that contains the principal's DES credential (in other words, the principal's home domain).
Secure RPC Netname Format
Principal Prefix Identifier Domain Example
User unix UID Domain containing user's password entry and the DES credential itself unix.24601@sales.wiz.com
Workstation unix hostname The domain name returned by executing the domainname command on that workstation unix.machine7@sales.wiz.com

Verification Field

The verification field is used to make sure the credential is not forged. It is generated from the credential information stored in the cred table.

The verification field is composed of:

How the DES Credential Is Generated

To generate its DES credential, the principal depends on the keylogin command, which must have been executed before the principal tries to generate its credential. The keylogin command (often referred to simply as a keylogin) is executed automatically when an NIS+ principal logs in.

Note: If the principal's login password is different from the principal's Secure RPC password, a successful keylogin cannot be performed. See Secure RPC Password versus Login Password Problem for a discussion of this situation.

The purpose of the keylogin is to give the principal access to the principal's private key. keylogin fetches the principal's private key from the cred table, decrypts it with the principal's Secure RPC password (remember that the private key was originally encrypted with the principal's Secure RPC password), and stores it locally with the keyserver for future NIS+ requests.

See figure for more information.

To generate its DES credential, the principal still needs the public key of the server to which it will send the request. This information is stored in the principal's directory object. Once the principal has this information, it can form the verification field of the credential.

First, the principal generates a random DES key for encrypting various credential information. The principal uses its own private key (stored in the keyserver) and the server's public key to generate a common key that is used to generate and encrypt the random DES key. It then generates a time stamp that is encrypted with the DES key and combines it with other credential-related information into the verification field. See figure for more information.

Secure RPC Password versus Login Password Problem

When a principal's login password is different from his or her Secure RPC password, keylogin cannot decrypt it at login time because keylogin defaults to using the principal's login password, and the private key was encrypted using the principal's Secure RPC password.

When this occurs, the principal can log in to the system, but for NIS+ purposes the principal is placed in the authorization class of nobody because the keyserver does not have a decrypted private key for that user. Since most NIS+ environments are set up to deny the nobody class create, destroy, and modify rights to most NIS+ objects, this results in "permission denied" errors when the user tries to access NIS+ objects.

To be placed in one of the other authorization classes, a user in this situation must explicitly run the keylogin program and give the principal's Secure RPC password when keylogin prompts for a password. (Note that in this context, network password is sometimes used as a synonym for Secure RPC password. When prompted for your network password, type your Secure RPC password.) (See the keylogin section.)

But an explicit keylogin provides only a temporary solution that is good only for the current login session. The keyserver now has a decrypted private key for the user, but the private key in the user's cred table is still encrypted using the user's Secure RPC password, which is different than the user's login password. The next time the user logs in, the same problem recurs. To permanently solve the problem the user needs to re-encrypt the private key in the cred table to one based on the user's login ID rather than the user's Secure RPC password. To do this, the user needs to run chkey -p as described in Changing Keys for a NIS+ Principal.

Thus, to permanently solve problems related to a difference in Secure RPC password and login password, the user (or an administrator acting for the user) must perform these steps:

  1. Login using the login password.
  2. Run the keylogin program to temporarily get a decrypted private key stored in the keyserver and thus gain temporary NIS+ access privileges.
  3. Run chkey -p to permanently change the encrypted private key in the cred table to one based on the user's login password.
  4. When you are ready to finish this login session, run keylogout.
  5. Log off the system with logout.

Cached Public Keys Problems

Occasionally, you may find that even though you have created the proper credentials and assigned the proper access rights, some principal requests still get denied. The most common cause of this problem is the existence of stale objects with old versions of a server's public key. You can usually correct this problem by:

Where Credential-Related Information Is Stored

This section describes where credential-related information is stored throughout the NIS+ namespace.

Credential-related information, such as public keys, is stored in many locations throughout the namespace. NIS+ updates this information periodically, depending on the time-to-live values of the objects that store it, but sometimes, between updates, it gets out of sync. As a result, you may find that operations that should work, do not. The following table lists all the objects, tables, and files that store credential-related information and how to reset it.

Where Credential-Related Information Is Stored
Item Stores To Reset or Change
cred table NIS+ principal's public key and private key. These are the master copies of these keys. Use nisaddcred to create new credentials; it updates existing credentials. An alternative is chkey.
directory object A copy of the public key of each server that supports it. Run the
/usr/lib/nis/nisupdkeys command on the directory object.
keyserver The secret key of the NIS+ principal that is currently logged in. Run keylogin for a principal user or keylogin -r for a principal workstation.
NIS+ daemon Copies of directory objects, which in turn contain copies of their servers' public keys. Kill the rpc.nisd daemon and the cache manager:
stopsrc -s rpc.nisd
stopsrc -s nis_cachemgr
then remove NIS_SHARED_DIRCACHE from /var/nis. Then restart both.
startsrc -s rpc.nisd
startsrc -s nis_cachemgr
Directory cache A copy of directory objects, which in turn contain copies of their servers' public keys. Kill the NIS+ cache manager and restart it. The -i option resets the directory cache from the cold-start file and restarts the cache manager.
stopsrc -s nis_cachemgr
startsrc -s nis_cachemgr -a "-i"
cold-start file A copy of a directory object, which in turn contains copies of its servers' public keys. On the root master, kill the NIS+ daemon and restart it. The daemon reloads new information into the existing NIS_COLD_START file.

On a client workstation, first remove the NIS_COLD_START and NIS_SHARED_DIRCACHE files from /var/nis, and use stopsrc -s nis_cachemgr to kill the cache manager. Then re-initialize the principal with nisinit -c. The principal's trusted server reloads new information into the workstation's NIS_COLD_START file.

Start the nis_cachemgr using startsrc -s nis_cachemgr.

passwd table A user's password. Use the passwd command. It changes the password in the NIS+ passwd table and updates it in the cred table.
passwd file A user's password or a workstation's superuser password. Use the passwd command, whether logged in as super user or as yourself, whichever is appropriate.

The Cred Table in Detail

Credential information for principals is stored in a cred table. The cred table is one of the standard NIS+ tables. Each domain has one cred table, which stores the credential information of client workstations that belong to that domain and client users who are allowed to log into them. (In other words, the principals of that domain.) The cred tables are located in their domains' org_dir subdirectory.

Attention: Never link a cred table. NIS+ does not operate correctly with linked cred tables. Each org_dir directory should have its own cred table. Do not use a link to some other org_dir cred table.

For users, the cred table stores LOCAL credential information for all users who are allowed to log into any of the machines in the domain. The cred table also stores DES credential information for those users that have the domain as their home domain.

You can view the contents of a cred table with the niscat command, described in Administering NIS+ Tables.

The cred table, as shown in the following table, has five columns:

Cred Table Credential Information
  NIS+ Principal Name Authentication Type Authentication
Name
Public Data Private Data
Column Name cname auth_type auth_name public_data private_data
User Fully qualified principal name LOCAL UID GID list  
Machine Fully qualified principal name DES Secure RPC netname Public key Encrypted Private key

The Authentication Type column, determines the types of values found in the other four columns.

Creating Credential Information

There are several methods of creating and administering credential information:

How nisaddcred Creates Credential Information

When used to create LOCAL credential information, nisaddcred simply extracts the principal user's UID (and GID) from the principal's login record and places it in the domain's cred table.

When used to create DES credential information, nisaddcred goes through a two-part process:

  1. Forming the principal's Secure RPC netname. A Secure RPC netname is formed by taking the principal's user ID number from the password record, attaching the unix prefix to it, and combining it with the domain name (unix.1050@wiz.com, for example).
  2. Generating the principal's private and public keys.

    To encrypt the private key, nisaddcred needs the principal's Secure RPC password. When the nisaddcred command is invoked with the des argument, it prompts the principal for a Secure RPC password. Normally, this password is the same as the principal's login password. (If it is different, the user will have to perform additional steps when logging in, as described in Secure RPC Password versus Login Password Problem.)

The nisaddcred command generates a pair of random, but mathematically related 192-bit authentication keys using the Diffie-Hellman cryptography scheme. These keys are called the Diffie-Hellman key-pair, or simply key-pair for short.

One of these is the private key, and the other is the public key. The public key is placed in the public data field of the cred table. The private key is placed in the private data field, but only after being encrypted with the principal's Secure RPC password. See figure.

The principal's private key is encrypted as a security precaution because the cred table, by default, is readable by all NIS+ principals, even unauthenticated ones.

Secure RPC Netname and NIS+ Principal Name

When creating credential information, you will often have to enter a principal's SecureRPC-netname and principal-name. Each has its own syntax:

Secure RPC netname
A Secure RPC netname is a name whose syntax is determined by the Secure RPC protocol. Therefore, it does not follow NIS+ naming conventions:

If a Secure RPC netname identifies a user, it requires the user's UID. If it identifies a workstation, it requires the workstation's host name. (When used with the nisaddcred command it is always preceded by the -p (lowercase) flag.)

A Secure RPC netname always begins with the unix (all lowercase) prefix and ends with a domain name. However, because it follows the Secure RPC protocol, the domain name does not contain a trailing dot.

Principal name
An NIS+ principal follows the normal NIS+ naming conventions, but it must always be fully qualified. the syntax is: principal.domain.

Whether it identifies a client user or a client workstation, it begins with the principal's name, followed by a dot and the complete domain name, ending in a dot. (When used with nisaddcred to create credential information, it is always preceded by the -P (uppercase) flag. When used to remove credential information, it does not use the -P flag.)

Creating Credential Information for the Administrator

When a namespace is first set up, credential information is created first for the administrators who will support the domain. Once they have credential information, they can create credential information for other administrators, client workstations, and client users.

When you try to create your own credential information, you run into a problem of circularity: you cannot create your own credential information unless you have Create rights to your domain's cred table, but if the NIS+ environment is properly set up, you cannot have such rights until you have credentials. You have to step out of the loop somehow. You can do this in one of two ways:

In either case, your credential information is thus created by another NIS+ principal. To create your own credential information, follow the instructions in Creating Credential Information for NIS+ Principals.

Creating Credential Information for NIS+ Principals

Credential information for NIS+ principals can be created any time after their domain has been set up; in other words, once a cred table exists.

To create credential information for an NIS+ principal:

Once those conditions are met, you can use the nisaddcred command with both the -p and -P options:

For LOCAL credentials:

nisaddcred -p uid -P principal-name local

For DES credentials:

nisaddcred -p  SecureRPC-netname -P  principal-name des

Remember these principles:

The following example creates both LOCAL and DES credential information for an NIS+ user named morena who has a UID of 11177. She belongs to the sales.wiz.com. domain, so this example enters her credential information from a principal machine of that domain:

salesclient# nisaddcred -p 11177 -P morena.sales.wiz.com. local
salesclient# nisaddcred -p unix.11177@sales.wiz.com -P morena.sales.wiz.com. des
Adding key pair for unix.11177@sales.wiz.com (morena.sales.wiz.com.).
Enter login password:

The proper response to the Enter login password: prompt is morena's login password. If you do not know her login password, you can use a dummy password that she can later change using chkey. The following table shows how another administrator, whose credential information you create using a dummy password, can then use chkey to change his or her own password. In this example, you create credential information for an administrator named eiji who has a UID of 119. eiji belongs to the root domain, so you would enter his credential information from the root master server which is named rmaster.

Creating Administrator Credentials: Command Summary
Tasks Commands
Create LOCAL credential information for eiji.
rmaster# nisaddcred -p 119 -P eiji.wiz.com. local
Create DES credential information for eiji.
rmaster# nisaddcred -p unix.119@wiz.com  -P eiji.wiz.com. des
Adding key pair for unix.119@wiz.com (eiji.wiz.com.).
Type dummy password for eiji.
Enter eiji's login password:
Re-enter dummy password.
nisaddcred: WARNING: password differs from login passwd.
Retype password:
You tell eiji the dummy password that you used.  
eiji logs into rmaster.
rmaster login:
 eiji
eiji enters real login password.
Password:
eiji gets error message but is allowed to log in anyway.
Password does not decrypt secret key for unix.119@wiz.com.
eiji runs keylogin.
rmaster% keylogin
eiji types dummy password.
Password: dummy-password
eiji runs chkey -p.
rmaster% chkey -p
Updating nisplus publickey database
Generating new key for 'unix.119@wiz.com'.
eiji types real login password.
Enter login password: 
eiji re-types real login password.
Retype password:
Done.

First, you would create eiji's credential information in the usual way, but using a dummy login password. NIS+ would warn you and ask you to re-type it. When you did, the operation would be complete. The domain's cred table would contain eiji's credential information based on the dummy password. The domain's passwd table (or /etc/passwd file), however, would still have his login password entry so that he can log on to the system.

Then, eiji would log in to the domain's master server, typing his correct login password (since the login procedure checks the password entry in the passwd table or /etc/passwd file). From there, eiji would first run keylogin, using the dummy password (since a keylogin checks the cred table), and then use the chkey -p command to change the cred entry to the real thing.

The two previous examples created credential information for a principal user while the principal user was logged in to the master server of the principal's home domain. However, if you have the proper access rights, you can create credential information in another domain. Simply append the domain name to this syntax:

For LOCAL credentials:

nisaddcred -p uid -P principal-name local domain-name

For DES credentials:

nisaddcred -p SecureRPC-netname -P principal-name des domain-name 

The following example first creates LOCAL and DES credential information for an administrator named chou in her home domain, which happens to be the root domain, then adds her LOCAL credential information to the sales.wiz.com domain. chou's UID is 11155. This command is typed on from the root master server. For simplicity, it assumes you are entering chou's correct login password.

rmaster# nisaddcred -p 11155 -P chou.wiz.com. local
rmaster# nisaddcred -p unix.11155@wiz.com -P chou.wiz.com. des
Adding key pair for unix.11155@wiz.com (chou.wiz.com.).
Enter login password:

rmaster# nisaddcred -p 11155 -P chou.wiz.com. local sales.wiz.com.

LOCAL credential information maps a UID to an NIS+ principal name. Although an NIS+ principal that is a client user can have different user IDs in different domains, it can have only one NIS+ principal name. So, if an NIS+ principal such as chou will be logging in from a domain other than her home domain, not only should she have a password entry in that domain, but also a LOCAL credential in that domain's cred table.

This example creates credential information for a principal workstation. Its host name is starshine1 and it belongs to the root domain. Therefore, its credential information is created from the root master server. In this example, you create them while logged in as root to the root master; however, if you already have valid credential information and the proper access rights, you could create them while logged in as yourself.

rmaster# nisaddcred -p unix.starshine1@wiz.com -P starshine1.wiz.com. des
Adding key pair for unix.starshine1@wiz.com
       (starshine1.wiz.com.).
Enter starshine1.wiz.com.'s root login password:
Retype password:

The proper response to the password prompt is the principal workstation's superuser password. Of course, you could use a dummy password that would later be changed by someone logged in as superuser to that principal workstation.

Administering NIS+ Credential Information

The following sections describe how to use the nisaddcred command to administer existing credential information. You must have create, modify, read, and destroy rights to the cred table to perform these operations.

Updating Your Own Credential Information

Updating your own credential information is considerably easier than creating it. Just type the simple versions of the nisaddcred command while logged in as yourself:

# nisaddcred des
# nisaddcred local

To update credential information for someone else, you simply perform the same procedure that you would use to create that person's credential information.

Removing Credential Information

The nisaddcred command removes a principal's credential information, but only from the local domain where the command is run.

Thus, to completely remove a principal from the entire system, you must explicitly remove that principal's credential information from the principal's home domain and all domains where the principal has LOCAL credential information.

To remove credential information, you must have modify rights to the local domain's cred table. Use the -r option and specify the principal with a full NIS+ principal name:

# nisaddcred -r principal-name

The following two examples remove the LOCAL and DES credential information of the administrator morena.wiz.com. The first example removes both types of credential information from her home domain (wiz.com.), the second removes her LOCAL credential information from the sales.wiz.com. domain. Note how they are each entered from the appropriate domain's master servers.

rmaster# nisaddcred -r morena.wiz.com.
salesmaster# nisaddcred -r morena.wiz.com.

To verify that the credential information was indeed removed, run nismatch on the cred table, as shown below. For more information about nismatch, see Administering NIS+ Tables.

rmaster# nismatch morena.wiz.com. cred.org_dir
salesmaster# nismatch morena.wiz.com. cred.org_dir


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]