[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Network Information Services (NIS and NIS+) Guide


Administering NIS+ Credentials

This section assumes that you have a basic understanding of the NIS+ security system, especially of the role that credentials play in that system (see Chapter 7, Security for this information).

This section provides the following information:

How Credentials Work

NIS+ uses an authentication system of credentials to prevent 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. Likewise, NIS+ cannot prevent a user with root privileges from assuming the identity of another user who is currently logged in on the same machine.

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

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, defined as follows:

Credential information
Data that is used to generate a DES credential and by the server to verify that credential.

DES credential
Bundle of numbers that is sent by the principal to the server to authenticate the principal. A principal's credential is generated and verified each time the principal makes an NIS+ request. See DES Credentials for a detailed description of the DES credential.

Authentication Components

For the authentication of credentials process to work correctly, the following components must be in place:

How Principals are Authenticated

The authentication process has three phases:

Preparation phase
Setup work performed by an NIS+ administrator prior to the user logging in; for example, creating credential information for the user.

Login phase
Actions taken by the system when a user logs in.

Request phase
Actions taken by the software when an NIS+ principal makes a request for a NIS+ service or access to an NIS+ object.

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

Preparation Phase

Before an NIS+ principal logs in, an NIS+ administrator must create DES credential information for that principal (user or machine). (NIS+ administrators should use the nisclient script to create credential information for users, as described in Using NIS+ Setup Scripts.) The administrator must:

Login Phase

When a principal logs in to the system, the following happens:

  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: If a principal's login password is different from their Secure RPC password, keylogin cannot decrypt it. Either the cannot decrypt message displays or the command fails without a message. For a discussion of this problem, see Secure RPC Password versus Login Password.
  2. The principal's decrypted private key is passed to the keyserver, which stores it for use during the request phase. The decrypted private key remains stored for use by the keyserver until the user does an explicit keylogout. If the user logs out (or goes home for the day without logging out), the decrypted private key remains stored in the server. If another user with root privileges on this user's machine switches to this user's login ID, the other user would then have use of this user's decrypted private key and could access NIS+ objects using this user's access authorization.

    Note: For added security, users should be cautioned to perform an explicit keylogout when they cease work. If they also log out of the system, they need only log back in when they return.

Request Phase

When an 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 for the following:

    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+ uses the current time of the principal's server and creates a time stamp that is encrypted using the DES key.
  6. NIS+ 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+ forms the principal's DES credential, which is composed of the following:
  8. NIS+ passes the following information to the server where the NIS+ object is stored:
  9. The object's server receives all of 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 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 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 ends with an error message. For example, if the time stamp is 9:00am and the window is one minute, then a request that is received and decrypted by the server after 9:01am 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 chronological sequence 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 is 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 is rejected.

      If the time stamp is within the window limit, and later 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.

DES Credentials

A DES credential consists of the following:

DES Credential Secure RPC Netname

The secure RPC netname of the DES 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 host name.

Domain name
Name of the domain that contains the principal's DES credential (in other words, the principal's home domain).

These components are further illustrated in the following table.

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 host name 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 a forgery. Field contents are 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 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 for a discussion of this situation.

The purpose of keylogin is to give the principal access to the principal's private key. keylogin obtains 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.

Figure 6-1. keylogin Generating a Principal's Private Key. This illustration shows cred table entries created by an administrator (the public key and the encrypted private key), which are decrypted by keylogin with the Secure RPC password, then stored by keyserver with the decrypted private key.



Figure cred_table not displayed.

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

Figure 6-2. Creating the DES Credential. This flowchart shows how DES credentials are generated. The decrypted private key and the server's public key combine to create the common key, which is encrypted with a random DES key and time stamped. The DES key, time stamp, window, and netname, become the DES credential.



Figure DES_key not displayed.

Secure RPC Password versus Login Password

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. Because most NIS+ environments are set up to deny create, destroy, and modify rights to the nobody class for 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. (See the The keylogin Process.)

Note: In this context, network password is sometimes used as a synonym for secure RPC password. When you are prompted for your network password, type your secure RPC password.

An explicit keylogin provides a temporary solution 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 from 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 by running chkey -p as described in Changing Keys for an NIS+ Principal.

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. Log in 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

Occasionally, you may find that even though you have created the appropriate credentials and assigned the appropriate access rights, some principal requests are still 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 them.

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. For example:

stopsrc -s rpc.nisd
stopsrc -s nis_cachemgr

Then remove NIS_SHARED_DIRCACHE from /var/nis. Then restart both. For example:

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 to change the password in the NIS+ passwd table and update it in the cred table.
passwd file A user's password or a workstation's root user password. Use the passwd command, whether logged in as root user or as yourself, whichever is appropriate.

The Cred Table in Detail

Credential information for principals is stored in a cred table, 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 in to them. Cred tables are located in each domain's 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 another org_dir cred table.

For users, the cred table stores LOCAL credential information for all users who are allowed to log in to any of the machines in the domain. The cred table also stores DES credential information for those users who 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 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 authentication types of values found in the other four columns:

LOCAL
If the authentication type is LOCAL, the other columns contain a principal user's name, UID, and GID. The last column is empty.

DES
If the authentication type is DES, the other columns contain a principal's name, secure RPC netname, public key, and encrypted private key. These keys are used in conjunction with other information to encrypt and decrypt a DES credential.

Creating Credential Information

You can use several methods to create and administer credential information:

How nisaddcred Creates Credential Information

When used to create local credential information, nisaddcred 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 must perform additional steps when logging in, as described in Secure RPC Password versus Login Password.)

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.

One of these keys 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.

Figure 6-3. How the nisaddcred Command Creates a Principal's Keys. This illustration shows how the Principal's network password and nisaddcred's private key are stored in cred table's private data. The public key generated by nisaddcred is stored in the table's public data.



Figure nisaddcred not displayed.

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 secure RPC netname and principal name. Each has its own syntax:

secure RPC netname
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 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
A name of an NIS+ principal. It 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 the secure RPC netname is used with nisaddcred to create credential information, it is always preceded by the -P 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, these administrators can create credential information for other administrators, client workstations, and client users.

When you try to create your own credential information, you find that you cannot create your own credential information unless you have Create rights to your domain's cred table,. However, if the NIS+ environment is properly set up, you cannot have such rights until you have credentials. You can remove the loop in one of two ways:

In either case, your credential information is 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 these conditions are met, you can use the nisaddcred command with both the -p and -P flags:

For local credentials, use the following example:

nisaddcred -p uid -P principal-name local

For DES credentials, use the following example:

nisaddcred -p  secureRPCnetname -P  principal-name des

Remember the following guidelines when you create credential information:

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 response to the Enter login password: prompt is morena's login password. If you do not know her login password, you can use a substitute 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:
Inform eiji of the dummy password that you used.  
eiji logs in to 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.

If you were creating credential information using the commands shown in the previous table, you would first create eiji's credential information in the usual way, but using a dummy login password. NIS+ would warn you and ask you to retype 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 in 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 substitute password (since a keylogin checks the cred table), and then use the chkey -p command to change the cred entry to the actual table entry.

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 by appending the domain name to this syntax:

For LOCAL credentials, use the following example:

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

For DES credentials, use the following example:

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. It then adds her LOCAL credential information to the sales.wiz.com. domain. Chou's UID is 11155. This command is entered from the root master server.

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

The following 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 credential information (while logged in as root user to the root master). However, if you already have valid credential information and the appropriate access rights, you can 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 correct response to the password prompt is the principal workstation's root user password. You could use a substitute password that is later changed by someone logged in as root user to that principal workstation.

Administering Credential Information

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

Updating Your Own Credential Information

Update your own credential information using the nisaddcred command while logged in as yourself:

# nisaddcred des
# nisaddcred local

To update credential information for someone else, perform the same procedure that you 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.

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 from 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 example removes her LOCAL credential information from the sales.wiz.com. domain. Note that 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


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]