Gestion d’un domaine sous Ubuntu – 6 – Gestion des comptes utilisateurs

6 – Gestion des comptes utilisateurs

OpenLDAP et Kerberos fonctionnent, voyons comment gérer les utilisateurs et les groupes

Installation

Nous allons d’abord installer quelques scripts de base pour la gestion de ldap :

sudo aptitude install ldapscripts

Puis, modifier le fichier de configuration « /etc/ldapscripts/ldapscripts.conf » :

# Copyright (C) 2005 Gana�l LAPLANCHE – Linagora
# Copyright (C) 2006-2011 Gana�l LAPLANCHE
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307,
# USA.

# Note for Debian users:
# On Debian system ldapscripts will try to parse and use some system config.
# Look on commented variables and description lines started with DEBIAN.
# But you could override it’s values here.

# LDAP server
# DEBIAN: values from /etc/pam_ldap.conf are used.
SERVER= »ldap://localhost »
BINDDN= »cn=admin,dc=exemple,dc=local »
# Suffixes
# DEBIAN: values from /etc/pam_ldap.conf are used.
SUFFIX= »dc=exemple,dc=local » # Global suffix
GSUFFIX= »ou=Groups » # Groups ou (just under $SUFFIX)
USUFFIX= »ou=Users » # Users ou (just under $SUFFIX)
MSUFFIX= »ou=Machines » # Machines ou (just under $SUFFIX)

# Authentication type
# If empty, use simple authentication
# Else, use the value as an SASL authentication mechanism
SASLAUTH= » »
#SASLAUTH= »GSSAPI »

# Simple authentication parameters
# DEBIAN: values from /etc/pam_ldap.conf are used.
# The following BIND* parameters are ignored if SASLAUTH is set
#BINDDN= »cn=Manager,dc=example,dc=com »
# The following file contains the raw password of the BINDDN
# Create it with something like : echo -n ‘secret’ > $BINDPWDFILE
# WARNING !!!! Be careful not to make this file world-readable
# DEBIAN: /etc/pam_ldap.secret or /etc/ldap.secret are used.
#BINDPWDFILE= »/etc/ldapscripts/ldapscripts.passwd »
# For older versions of OpenLDAP, it is still possible to use
# unsecure command-line passwords by defining the following option
# AND commenting the previous one (BINDPWDFILE takes precedence)
#BINDPWD= »secret »

# Start with these IDs *if no entry found in LDAP*
GIDSTART= »10000″ # Group ID
UIDSTART= »10000″ # User ID
MIDSTART= »20000″ # Machine ID

# Group membership management
# ObjectCLass used for groups
# Possible values : posixGroup, groupOfNames, groupOfUniqueNames (case-sensitive !)
# Warning : when using groupOf*, be sure to be compliant with RFC 2307bis (AUXILIARY posixGroup).
# Also, do not mix posixGroup and groupOf* entries up in you directory as, within RFC 2307bis,
# the former is a subset of the latter. The ldapscripts wouldn’t cope well with this configuration.
GCLASS= »posixGroup » # Leave « posixGroup » here if not sure !
# When using groupOfNames or groupOfUniqueNames, creating a group requires an initial
# member. Specify it below, you will be able to remove it once groups are populated.
#GDUMMYMEMBER= »uid=dummy,$USUFFIX,$SUFFIX »

# User properties
# DEBIAN: values from /etc/adduser.conf are used.
#USHELL= »/bin/sh »
#UHOMES= »/home/%u » # You may use %u for username here
CREATEHOMES= »yes » # Create home directories and set rights ?
#HOMESKEL= »/etc/skel » # Directory where the skeleton files are located. Ignored if undefined or nonexistant.
#HOMEPERMS= »755″ # Default permissions for home directories

# User passwords generation
# Command-line used to generate a password for added users.
# You may use %u for username here ; special value «  » will ask for a password interactively
# WARNING !!!! This is evaluated, everything specified here will be run !
# WARNING(2) !!!! Some systems (Linux) use a blocking /dev/random (waiting for enough entropy).
# In this case, consider using /dev/urandom instead.
#PASSWORDGEN= »cat /dev/random | LC_ALL=C tr -dc ‘a-zA-Z0-9’ | head -c8″
#PASSWORDGEN= »pwgen »
#PASSWORDGEN= »echo changeme »
#PASSWORDGEN= »echo %u »
#PASSWORDGEN= » »
PASSWORDGEN= »pwgen »

# User passwords recording
# you can keep trace of generated passwords setting PASSWORDFILE and RECORDPASSWORDS
# (useful when performing a massive creation / net rpc vampire)
# WARNING !!!! DO NOT FORGET TO DELETE THE GENERATED FILE WHEN DONE !
# WARNING !!!! DO NOT FORGET TO TURN OFF RECORDING WHEN DONE !
RECORDPASSWORDS= »no »
PASSWORDFILE= »/var/log/ldapscripts_passwd.log »

# Where to log
LOGFILE= »/var/log/ldapscripts.log »

# Temporary folder
TMPDIR= »/tmp »

# Various binaries used within the scripts
# Warning : they also use uuencode, date, grep, sed, cut, expr, which…
# Please check they are installed before using these scripts
# Note that many of them should come with your OS

# OpenLDAP client commands
LDAPSEARCHBIN= »/usr/bin/ldapsearch »
LDAPADDBIN= »/usr/bin/ldapadd »
LDAPDELETEBIN= »/usr/bin/ldapdelete »
LDAPMODIFYBIN= »/usr/bin/ldapmodify »
LDAPMODRDNBIN= »/usr/bin/ldapmodrdn »
LDAPPASSWDBIN= »/usr/bin/ldappasswd »

# Character set conversion : $ICONVCHAR UTF-8
# Comment ICONVBIN to disable UTF-8 conversion
#ICONVBIN= »/usr/bin/iconv »
#ICONVCHAR= »ISO-8859-15″

# Base64 decoding
# Comment UUDECODEBIN to disable Base64 decoding
#UUDECODEBIN= »/usr/bin/uudecode »

# Getent command to use – choose the ones used
# on your system. Leave blank or comment for auto-guess.
# GNU/Linux
#GETENTPWCMD= »getent passwd »
#GETENTGRCMD= »getent group »
# FreeBSD
#GETENTPWCMD= »pw usershow »
#GETENTGRCMD= »pw groupshow »
# Auto
GETENTPWCMD= » »
GETENTGRCMD= » »

# You can specify custom LDIF templates here
# Leave empty to use default templates
# See *.template.sample for default templates
#GTEMPLATE= »/path/to/ldapaddgroup.template »
#UTEMPLATE= »/path/to/ldapadduser.template »
#MTEMPLATE= »/path/to/ldapaddmachine.template »
GTEMPLATE= » »
UTEMPLATE= » »
MTEMPLATE= » »

En lisant les commentaires du fichier, on peut voir que ldapscript lit le mot de passe admin de LDAP dans le fichier /etc/ldap.secret.

Les commandes suivantes vont permettre de créer ce fichier, d’y écrire le mot de passe et de le chiffrer. (remplacez MonMotDePasse par votre mot de passe admin de LDAP)

sudo sh -c « echo -n ‘MonMotDePasse’ > /etc/ldap.secret »
sudo chmod 400 /etc/ldap.secret

 

Les commentaires expliquent également que le fichier « /etc/adduser.conf » est utilisé pour déterminer le répertoire home par défaut. Ubuntu autorise les utilisateurs à voir le contenu des répertoires home des autres utilisateurs.
Dans un réseau à la maison, ça ne porte pas à conséquence, mais pour une utilisation professionnelle, changez DIR_MODE=0755 en DIR_MODE=0700.

 

Gestion des utilisateurs

Nous pouvons maintenant créer les utilisateurs.

Nous utiliserons le groupe “admin” pour les administrateurs (par défaut pour Ubuntu), ce qui donnera les droits admin à ces utilisateurs sur toutes les machines du réseau sans configuration supplémentaire.
Néanmoins, ce groupe existe déjà localement, nous devons faire attention à ne pas perdre les droits admin sur le serveur.

La première chose à faire est de créer un mot de passe pour notre premier utilisateur administrateur. L’authentification se fait par l’intermédiaire de Kerberos, nous devons donc créer le « principal » de l’utilisateur :

sudo kadmin.local -q « addprinc MonUtilisateur »

Nous avons besoin de groupe pour « organiser » les utilisateurs. Les deux premiers groupes que nous allons créer seront “domainadmins” et “domainusers” :

sudo ldapaddgroup domainadmins
sudo ldapaddgroup domainusers

Ensuite, nous créons un utilisateur ldap et le plaçons dans le groupe des admins :

sudo ldapadduser MonUtilisateur domainadmins

Et finalement, nous ajoutons cet utilisateur au groupe des utilisateurs :

sudo ldapaddusertogroup MonUtilisateur domainusers

 

Vous pouvez maintenant vous loguer avec cet utilisateur sur le serveur (et par la suite sur les autres machines)
Si vous voulez que le groupe domainadmins ai un accès sudo sur le serveur, lancez la commande suivante :

sudo visudo

 

Modifiez le fichier comme suit :

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
%domainadmins ALL=(ALL:ALL) ALL

 

Webographie :

http://www.danbishop.org/2012/06/02/ubuntu-12-04-ultimate-server-guide-first-draft/6/#part-6-account-management

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.