Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:redhat:rh124en:l105 [2024/11/11 13:36] – admin | elearning:workbooks:redhat:rh124en:l105 [2024/11/26 13:43] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2024.01** | + | Version: **2024.01** |
- | Last update : ~~LASTMOD~~ | + | Last update: ~~LASTMOD~~ |
- | ======RH12406 - User management====== | + | ======RH12406 - User Management====== |
=====Contents===== | =====Contents===== | ||
Ligne 14: | Ligne 14: | ||
* / | * / | ||
* Querying databases | * Querying databases | ||
- | * The /etc/group and / | + | * The /etc/group and / |
- | * The /etc/passwd and / | + | * The /etc/passwd and / |
* Commands | * Commands | ||
* Groups | * Groups | ||
Ligne 43: | Ligne 43: | ||
</ | </ | ||
- | Good user management involves a good group strategy. In fact, each user is assigned to a **main** group but can also be a member of one or more secondary groups. | + | Good user management involves a good group strategy. In fact, each user is assigned to a **primary** group but can also be a member of upto 15 secondary groups. |
As in other operating systems, under Linux it is preferable to give access rights to groups and not to individual users. | As in other operating systems, under Linux it is preferable to give access rights to groups and not to individual users. | ||
Ligne 53: | Ligne 53: | ||
* **/ | * **/ | ||
- | ====/ | + | ====/ |
< | < | ||
Ligne 153: | Ligne 153: | ||
</ | </ | ||
- | In this file : | + | In this file: |
* **sss** indicates the use of the **System Security Services Daemon** (SSSD). | * **sss** indicates the use of the **System Security Services Daemon** (SSSD). | ||
- | * SSSD has its origines in the **FreeIPA** (Identity, Policy and Audit) and provides Linux/Unix networks with similar functionalities as those provided by Microsoft Active Directory Domain Services to Windows(tm) networks, | + | * SSSD has its origines in **FreeIPA** (Identity, Policy and Audit) and provides Linux/Unix networks with similar functionalities as those provided by Microsoft Active Directory Domain Services to Windows(tm) networks, |
* For more information, | * For more information, | ||
* **files** indicates the use of local text files in **/etc**, | * **files** indicates the use of local text files in **/etc**, | ||
Ligne 165: | Ligne 165: | ||
The **getent** command is used to query databases. It takes the following form: | The **getent** command is used to query databases. It takes the following form: | ||
- | getent database-key | + | getent database key |
- | For example, to search for the user in the user database, use the following command: | + | For example, to search for a user in the user database, use the following command: |
< | < | ||
Ligne 181: | Ligne 181: | ||
</ | </ | ||
- | Using the getent command without specifying a key prints the contents of the database | + | Using the getent command without specifying a key prints the contents of the database |
< | < | ||
Ligne 224: | Ligne 224: | ||
</ | </ | ||
- | ====Files /etc/group and / | + | ====The /etc/group and / |
To list the existing groups on the system, enter the following command: | To list the existing groups on the system, enter the following command: | ||
Ligne 293: | Ligne 293: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: | + | **Important**: |
</ | </ | ||
Ligne 371: | Ligne 371: | ||
Each line consists of 4 fields: | Each line consists of 4 fields: | ||
- | * The group name. This field is used to link to the **/ | + | * The unique |
- | * The **encrypted** group password | + | * The encrypted group password. |
* The group administrator if one exists, | * The group administrator if one exists, | ||
- | * The list of members | + | * The list of users who have the group as a secondary group. |
To check the **/ | To check the **/ | ||
Ligne 382: | Ligne 382: | ||
[root@redhat9 ~]# | [root@redhat9 ~]# | ||
</ | </ | ||
- | |||
- | In the event that your files do not contain any errors, you will find yourself returned to the prompt. | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: | + | **Important**: |
</ | </ | ||
Ligne 396: | Ligne 394: | ||
* regenerates the **/ | * regenerates the **/ | ||
- | ==== Files /etc/passwd and / | + | ==== The /etc/passwd and / |
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
Ligne 454: | Ligne 452: | ||
* The password. A value of **x** in this field indicates that the system uses the **/ | * The password. A value of **x** in this field indicates that the system uses the **/ | ||
* THE UID. A unique value used to determine rights to files and directories. | * THE UID. A unique value used to determine rights to files and directories. | ||
- | * GID. A value indicating the user's **main** group. | + | * GID. A value indicating the user's **primary** group. |
* The full name. This optional field is also called **GECOS**. | * The full name. This optional field is also called **GECOS**. | ||
* The user's home directory | * The user's home directory | ||
Ligne 506: | Ligne 504: | ||
* The user's name. This field is used to make the link with the **/ | * The user's name. This field is used to make the link with the **/ | ||
* The user's **encrypted** password. Encryption is **one-way**. This field can also contain one of the following three values: | * The user's **encrypted** password. Encryption is **one-way**. This field can also contain one of the following three values: | ||
- | **!!** - The password has not yet been set and the user cannot log in, | + | |
- | ***** - The user cannot log in, | + | |
- | **empty** - No password will be requested for this user, | + | |
* The number of days between **01/ | * The number of days between **01/ | ||
* The number of days that the password is still valid. A value of **0** in this field indicates that the password never expires, | * The number of days that the password is still valid. A value of **0** in this field indicates that the password never expires, | ||
Ligne 524: | Ligne 522: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: | + | **Important**: |
</ | </ | ||
Ligne 531: | Ligne 529: | ||
* **pwconv** | * **pwconv** | ||
* regenerates the **/ | * regenerates the **/ | ||
- | **pwunconv** | + | |
* regenerates the **/ | * regenerates the **/ | ||
Ligne 564: | Ligne 562: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important** : It is possible to create several groups with the same GID. | + | **Important**: |
</ | </ | ||
- | < | + | < |
**Important**: | **Important**: | ||
</ | </ | ||
Ligne 625: | Ligne 623: | ||
===gpasswd=== | ===gpasswd=== | ||
- | This command is used to modify | + | This command is used to administer |
==Command Line Switches== | ==Command Line Switches== | ||
Ligne 656: | Ligne 654: | ||
^ Return code ^ Description ^ | ^ Return code ^ Description ^ | ||
| 1 | Unable to update /etc/passwd file | | | 1 | Unable to update /etc/passwd file | | ||
- | | 2 | Syntax invalid | + | | 2 | Invalid syntax |
| 3 | Invalid option | | | 3 | Invalid option | | ||
| 4 | The requested UID is already in use | | | 4 | The requested UID is already in use | | ||
| 6 | The specified group does not exist | | | 6 | The specified group does not exist | | ||
| 9 | The specified user name already exists | | | 9 | The specified user name already exists | | ||
- | | 10 | Unable to update /etc/group file | | + | | 10 | Unable to update |
- | | 12 | Unable to create user home directory | | + | | 12 | Unable to create |
- | | 13 | Unable to create user's mail spool | | + | | 13 | Unable to create |
==Command Line Switches== | ==Command Line Switches== | ||
Ligne 712: | Ligne 710: | ||
</ | </ | ||
- | < | + | < |
**Important**: | **Important**: | ||
</ | </ | ||
Ligne 813: | Ligne 811: | ||
</ | </ | ||
- | < | + | < |
- | **Important** : Note the **-l** option, which locks an account by placing the character **!** in front of the encrypted password. | + | **Important**: |
</ | </ | ||
Ligne 862: | Ligne 860: | ||
In this file we find the following directives: | In this file we find the following directives: | ||
- | * **GROUP** - identifies the user's default | + | * **GROUP** - identifies the user's default |
* **HOME** - indicates that the user's home directory will be created in the **home** directory when the account is created if this option has been enabled in the **/ | * **HOME** - indicates that the user's home directory will be created in the **home** directory when the account is created if this option has been enabled in the **/ | ||
* **INACTIVE** - indicates the number of days of inactivity after a password has expired before the account is locked. A value of -1 disables this directive, | * **INACTIVE** - indicates the number of days of inactivity after a password has expired before the account is locked. A value of -1 disables this directive, | ||
- | * **EXPIRE** - no value, this directive indicates that the user's password never expires, | + | * **EXPIRE** - with no value, this directive indicates that the user's password never expires, |
* **SHELL** - specifies the user's shell, | * **SHELL** - specifies the user's shell, | ||
* **SKEL** - indicates the directory containing the files that will be copied to the user's home directory, if this directory is created when the user is created, | * **SKEL** - indicates the directory containing the files that will be copied to the user's home directory, if this directory is created when the user is created, | ||
Ligne 949: | Ligne 947: | ||
=====LAB #1 - Manage Users and Groups===== | =====LAB #1 - Manage Users and Groups===== | ||
- | Now create three groups **group1**, **group2** and **group3**. The GID value of group **group3** must be **1807** : | + | Now create three groups **group1**, **group2** and **group3**. The GID value of group **group3** must be **1807**: |
< | < | ||
Ligne 955: | Ligne 953: | ||
</ | </ | ||
- | Now create three users **fenestros1**, | + | Now create three users **fenestros1**, |
< | < | ||
Ligne 995: | Ligne 993: | ||
</ | </ | ||
- | Create the password **fenestros** for **group3** : | + | Create the password **fenestros** for **group3**: |
< | < | ||
Ligne 1008: | Ligne 1006: | ||
</ | </ | ||
- | Check the **/ | + | Check the **/ |
< | < | ||
Ligne 1027: | Ligne 1025: | ||
</ | </ | ||
- | Now name **fenestros1** administrator of **group3** : | + | Now name **fenestros1** administrator of **group3**: |
< | < | ||
Ligne 1050: | Ligne 1048: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: | + | **Important**: |
</ | </ | ||
Ligne 1064: | Ligne 1062: | ||
</ | </ | ||
- | So delete the user **fenestros3** : | + | So delete the user **fenestros3**: |
< | < | ||
Ligne 1100: | Ligne 1098: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important** : The **find** command is run iteratively. The error is normal because when the **find** command finds no more files to delete, it stops with a return code of 2. | + | **Important**: |
</ | </ | ||
Ligne 1122: | Ligne 1120: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important** : Note that the rules governing the use of passwords are not applied to users created by root. Also note that passwords entered will **NOT** be visible. | + | **Important**: |
</ | </ | ||
Ligne 1260: | Ligne 1258: | ||
[root@redhat9 ~]# cat / | [root@redhat9 ~]# cat / | ||
#%PAM-1.0 | #%PAM-1.0 | ||
- | auth substack system-auth | + | auth |
- | auth include postlogin | + | auth |
- | account required pam_nologin.so | + | account |
- | account include system-auth | + | account |
- | password include system-auth | + | password |
# pam_selinux.so close should be the first session rule | # pam_selinux.so close should be the first session rule | ||
- | session required pam_selinux.so close | + | session |
- | session required pam_loginuid.so | + | session |
# pam_selinux.so open should only be followed by sessions to be executed in the user context | # pam_selinux.so open should only be followed by sessions to be executed in the user context | ||
- | session required pam_selinux.so open | + | session |
- | session required pam_namespace.so | + | session |
- | session optional pam_keyinit.so force revoke | + | session |
- | session include system-auth | + | session |
- | session include postlogin | + | session |
- | -session optional pam_ck_connector.so | + | -session |
</ | </ | ||
Ligne 1288: | Ligne 1286: | ||
^ Type ^ Description | ^ Type ^ Description | ||
| **auth** | Used to authenticate a user or system prerequisites ( for example / | | **auth** | Used to authenticate a user or system prerequisites ( for example / | ||
- | | **account** | Used to check whether the user can authenticate (e.g. account validity). | + | | **account** | Used to check whether the user can authenticate (e.g. account validity). |
- | | **password** | Used to check whether the user has the rights to update the authentication mechanism. | + | | **password** | Used to check whether the user has the rights to update the authentication mechanism. |
- | | **session** | Used to manage the session after authentication (for example, mount a directory). | + | | **session** | Used to manage the session after authentication (for example, mount a directory). |
The **second field** is the // | The **second field** is the // | ||
^ Control-flag ^ Description ^ | ^ Control-flag ^ Description ^ | ||
- | | **required** | Successful completion of this module is essential. The failure of a // | + | | **required** | Successful completion of this module is essential. The failure of a // |
- | | **requisite** | This module must be passed. Failure of a // | + | | **requisite** | This module must succeed. Failure of a // |
- | | **sufficient** | Passing this module | + | | **sufficient** | Success |
- | | **optional** | The success or failure of this module is irrelevant, **unless** it is the only module to be executed. | + | | **optional** | The success or failure of this module is irrelevant, **unless** it is the only module to be executed. |
- | | **include** | This control flag is used to include all lines of the same //module type// in the file specified as an argument. | + | | **include** | This control flag is used to include all lines of the same //module type// in the file specified as an argument. |
The **third field** specifies the // | The **third field** specifies the // | ||
Ligne 1305: | Ligne 1303: | ||
The **fourth field** may contain the **arguments**. | The **fourth field** may contain the **arguments**. | ||
- | PAM now offers a solution for all applications that do not have their own PAM configuration files. This solution takes the form of the **/ | + | PAM also offers a solution for all applications that do not have their own PAM configuration files. This solution takes the form of the **/ |
< | < | ||
Ligne 1341: | Ligne 1339: | ||
| **time.conf** | Used by the pam_time.so module | | | **time.conf** | Used by the pam_time.so module | | ||
- | Password complexity is managed by the pam_pwquality.so module. In order to set up a complex password policy, the **/ | + | Password complexity is managed by the **pam_pwquality.so** module. In order to set up a complex password policy, the **/ |
< | < | ||
Ligne 1618: | Ligne 1616: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: | + | **Important**: |
</ | </ | ||
----- | ----- | ||
Copyright © 2024 Hugh Norris. | Copyright © 2024 Hugh Norris. |