Dernière mise-à-jour : 2020/01/30 03:27
Weight: 5
Description: Candidates should be able to set up a Samba server for various clients. This objective includes setting up Samba as a standalone server as well as integrating Samba as a member in an Active Directory. Furthermore, the configuration of simple CIFS and printer shares is covered. Also covered is a configuring a Linux client to use a Samba server. Troubleshooting installations is also tested.
Key Knowledge Areas:
Terms and Utilities:
Le fonctionnement d'un réseau Windows™ se repose sur le protocole CIFS (Common Internet FileSystem) le successeur du protocole SMB (Server Message Block).
Les réseaux Microsoft™ se divisent en trois types distincts :
Le fonctionnement du client Windows™ 2000 et les versions ultérieures implique que le protocole SMB s'appuie directement sur TCP/IP en utilisant le port 445.
Le fonctionnement du client Windows™ antérieur à Windows™ 2000 nécessite le protocole NBT (Network Basic Import/Export System over TCP/IP) qui utilise les ports suivants :
Un nom NetBIOS est codé sur 16 octets dont les 15 premiers sont définis par l'utilisateur. Le dernier contient une valeur hexadécimale qui indique le type de ressource fournie par le système :
Valeur Hexadécimale | Type de Ressource |
---|---|
00 | Standard Workstation |
03 | Messenger Service |
06 | RAS Server Service |
21 | RAS Client Service |
1B | Domain Master Browser Service |
1D | Master Browser Name |
20 | Fileserver et/ou Printserver |
BE | Network Monitor Agent |
BF | Network Monitor Utility |
Les noms NetBIOS peuvent aussi être utilisés pour des noms de groupes :
Valeur Hexadécimale | Type de Ressource |
---|---|
00 | Standard Workstation Group |
1C | Logon Server |
1D | Master Browser Name |
1E | Normal Group Name |
Important : Le nom NetBIOS ne doit pas contenir les charactères suivants : “ / \ [ ] : ; | = , ^ * ? > <
La commande Windows™ NBTSTAT peut être utilisée pour visualiser la liste des types de ressources et les noms NetBIOS :
C:\Documents and Settings\Administrateur>NBTSTAT -n Connexion au réseau local: Adresse IP du noeud : [192.168.1.29] ID d'étendue : [] Table nom local NetBIOS Nom Type Statut --------------------------------------------- WINDOWS-FFC9AFA<00> UNIQUE Inscrit WORKGROUP <00> Groupe Inscrit WINDOWS-FFC9AFA<20> UNIQUE Inscrit WORKGROUP <1E> Groupe Inscrit
Le serveur Samba est en réalité un ensemble de programmes qui permettent le partage de fichiers et d'imprimantes entre un serveur Unix ou Linux et des stations Windows™ ( 3.11, 9x, NT4, 2000, XP, Vista, 2003, Seven et 10 ) ainsi que des stations OS/2 , Linux et Mac.
Le serveur Samba3 était capable offrir :
Le serveur Samba n'est pas capable d'offrir :
Samba4 apporte les nouveautés suivantes :
Samba se repose sur trois Daemons (Disk And Extension MONitor) :
Samba propose un nombre important de commandes et utilitaires :
Commande | Description |
---|---|
findsmb | Obtention d'informations sur les systèmes utilisant le protocole SMB |
net | Commande similaire à la commande Windows™ du même nom |
nmblookup | Interrogation d'un serveur de noms NetBIOS |
pdbedit | Gestion de comptes stockés dans une base de données SAM |
rpcclient | Exécution de programmes d'administration sur des clients Windows™ |
smbcacls | Gestion des ACL |
smbclient | Programme interactif multifonction |
smbcontrol | Interrogations simples auprès des deamons |
smbmount | Montage des ressources SMB sous Linux |
smbpasswd | Gestion des mots de passe |
smbspool | Gestion des impressions |
smbstatus | Etat des connexions |
smbtar | Utilitaire de sauvegarde |
smbumount | Démontage d'une ressource SMB sous Linux |
swat | Utilitaire de configuration |
testparm | Vérification du fichier de configuration |
testprns | Vérification des informations sur les imprimantes |
wbinfo | Interrogation du deamon winbindd |
Important : Configurez votre machine virtuelle CentOS 7 en mode réseau ponté avant de la démarrer.
Désactivez SELINUX afin de ne pas avoir des erreurs de ce dernier :
[root@centos7 /]# setenforce permissive [root@centos7 /]# getenforce Permissive
Editez ensuite le fichier /etc/sysconfig/selinux ainsi :
[root@centos7 /]# vi /etc/sysconfig/selinux [root@centos7 /]# cat /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
Afin d'éviter les problèmes liés au pare-feu arrêtez le service firewalld :
[root@centos7 /]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2017-07-28 11:10:59 CEST; 42min ago Docs: man:firewalld(1) Main PID: 616 (firewalld) CGroup: /system.slice/firewalld.service └─616 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Jul 28 11:10:52 centos7.fenestros.loc systemd[1]: Starting firewalld - dynamic firewall daemon... Jul 28 11:10:59 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. [root@centos7 /]# systemctl stop firewalld.service [root@centos7 /]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@centos7 /]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) Jul 28 11:10:52 centos7.fenestros.loc systemd[1]: Starting firewalld - dynamic firewall daemon... Jul 28 11:10:59 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. Jul 28 11:54:00 centos7.fenestros.loc systemd[1]: Stopping firewalld - dynamic firewall daemon... Jul 28 11:54:00 centos7.fenestros.loc systemd[1]: Stopped firewalld - dynamic firewall daemon.
Modifiez ensuite le fichier /etc/hosts pour définir votre hostname et votre adresse IP :
[root@centos7 ~]# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.1.103 centos7.fenestros.loc
Important : Modifiez l'adresse IP dans votre fichier /etc/hosts en fonction de votre adresse IP réelle.
Maintenant installez le paquet samba-swat :
[root@centos7 ~]# yum install samba-swat Loaded plugins: fastestmirror, langpacks adobe-linux-x86_64 | 2.9 kB 00:00:00 base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): adobe-linux-x86_64/primary_db | 2.7 kB 00:00:00 (2/3): extras/7/x86_64/primary_db | 191 kB 00:00:00 (3/3): updates/7/x86_64/primary_db | 7.8 MB 00:00:47 Determining fastest mirrors * base: centos.mirrors.ovh.net * extras: mirrors.standaloneinstaller.com * updates: mirrors.standaloneinstaller.com Resolving Dependencies --> Running transaction check ---> Package samba.x86_64 0:4.4.4-14.el7_3 will be installed --> Processing Dependency: samba-libs = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Processing Dependency: samba-common-tools = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Processing Dependency: samba-common-libs = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Processing Dependency: samba-common = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Processing Dependency: samba-client-libs = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Processing Dependency: libwbclient = 4.4.4-14.el7_3 for package: samba-4.4.4-14.el7_3.x86_64 --> Running transaction check ---> Package libwbclient.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package libwbclient.x86_64 0:4.4.4-14.el7_3 will be an update ---> Package samba-client-libs.x86_64 0:4.4.4-12.el7_3 will be updated --> Processing Dependency: samba-client-libs = 4.4.4-12.el7_3 for package: samba-client-4.4.4-12.el7_3.x86_64 --> Processing Dependency: samba-client-libs = 4.4.4-12.el7_3 for package: libsmbclient-4.4.4-12.el7_3.x86_64 ---> Package samba-client-libs.x86_64 0:4.4.4-14.el7_3 will be an update ---> Package samba-common.noarch 0:4.4.4-12.el7_3 will be updated ---> Package samba-common.noarch 0:4.4.4-14.el7_3 will be an update ---> Package samba-common-libs.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package samba-common-libs.x86_64 0:4.4.4-14.el7_3 will be an update ---> Package samba-common-tools.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package samba-common-tools.x86_64 0:4.4.4-14.el7_3 will be an update ---> Package samba-libs.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package samba-libs.x86_64 0:4.4.4-14.el7_3 will be an update --> Running transaction check ---> Package libsmbclient.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package libsmbclient.x86_64 0:4.4.4-14.el7_3 will be an update ---> Package samba-client.x86_64 0:4.4.4-12.el7_3 will be updated ---> Package samba-client.x86_64 0:4.4.4-14.el7_3 will be an update --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================= Installing: samba x86_64 4.4.4-14.el7_3 updates 610 k Updating for dependencies: libsmbclient x86_64 4.4.4-14.el7_3 updates 126 k libwbclient x86_64 4.4.4-14.el7_3 updates 100 k samba-client x86_64 4.4.4-14.el7_3 updates 547 k samba-client-libs x86_64 4.4.4-14.el7_3 updates 4.6 M samba-common noarch 4.4.4-14.el7_3 updates 191 k samba-common-libs x86_64 4.4.4-14.el7_3 updates 161 k samba-common-tools x86_64 4.4.4-14.el7_3 updates 451 k samba-libs x86_64 4.4.4-14.el7_3 updates 260 k Transaction Summary ======================================================================================================================================= Install 1 Package Upgrade ( 8 Dependent packages) Total download size: 7.0 M Is this ok [y/d/N]: y
Les paquets ainsi installés sont :
[root@centos7 ~]# rpm -qa | grep samba samba-libs-4.4.4-14.el7_3.x86_64 samba-client-4.4.4-14.el7_3.x86_64 samba-client-libs-4.4.4-14.el7_3.x86_64 samba-common-tools-4.4.4-14.el7_3.x86_64 samba-common-4.4.4-14.el7_3.noarch samba-4.4.4-14.el7_3.x86_64 samba-common-libs-4.4.4-14.el7_3.x86_64
Les deamons smb et nmb ne sont pas démarrés :
[root@centos7 ~]# systemctl status smb ● smb.service - Samba SMB Daemon Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@centos7 ~]# systemctl status nmb ● nmb.service - Samba NMB Daemon Loaded: loaded (/usr/lib/systemd/system/nmb.service; disabled; vendor preset: disabled) Active: inactive (dead)
Notez que le démarrage automatique de Samba n'est pas configuré. Configurez donc le démarrage automatique de Samba :
[root@centos7 ~]# systemctl enable smb Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service. [root@centos7 ~]# systemctl enable nmb Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
La configuration de Samba est obtenue en éditant le fichier /etc/samba/smb.conf. Lors de l'installation des paquets Samba, un fichier smb.conf minimaliste est créé. Vérifiez ce fichier à l'aide de la commande testparm :
[root@centos7 ~]# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions # Global parameters [global] workgroup = SAMBA printcap name = cups security = USER idmap config * : backend = tdb cups options = raw [homes] comment = Home Directories browseable = No inherit acls = Yes read only = No valid users = %S %D%w%S [printers] comment = All Printers path = /var/tmp browseable = No printable = Yes create mask = 0600 [print$] comment = Printer Drivers path = /var/lib/samba/drivers create mask = 0664 directory mask = 0775 write list = root
Démarrez maintenant les daemons smb et nmb et constatez les processus ainsi créés :
[root@centos7 ~]# systemctl start smb [root@centos7 ~]# systemctl start nmb [root@centos7 ~]# systemctl status smb ● smb.service - Samba SMB Daemon Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-07-29 11:53:31 CEST; 11s ago Main PID: 6793 (smbd) Status: "smbd: ready to serve connections..." CGroup: /system.slice/smb.service ├─6793 /usr/sbin/smbd ├─6794 /usr/sbin/smbd ├─6795 /usr/sbin/smbd └─6796 /usr/sbin/smbd Jul 29 11:53:31 centos7.fenestros.loc systemd[1]: Starting Samba SMB Daemon... Jul 29 11:53:31 centos7.fenestros.loc smbd[6793]: [2017/07/29 11:53:31.692284, 0] ../lib/util/become_daemon.c:124(daemon_ready) Jul 29 11:53:31 centos7.fenestros.loc systemd[1]: Started Samba SMB Daemon. Jul 29 11:53:31 centos7.fenestros.loc smbd[6793]: STATUS=daemon 'smbd' finished starting up and ready to serve connections [root@centos7 ~]# systemctl status nmb ● nmb.service - Samba NMB Daemon Loaded: loaded (/usr/lib/systemd/system/nmb.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-07-29 11:53:36 CEST; 15s ago Main PID: 6825 (nmbd) Status: "nmbd: ready to serve connections..." CGroup: /system.slice/nmb.service └─6825 /usr/sbin/nmbd Jul 29 11:53:36 centos7.fenestros.loc systemd[1]: Starting Samba NMB Daemon... Jul 29 11:53:36 centos7.fenestros.loc nmbd[6825]: [2017/07/29 11:53:36.108613, 0] ../lib/util/become_daemon.c:124(daemon_ready) Jul 29 11:53:36 centos7.fenestros.loc systemd[1]: Started Samba NMB Daemon. Jul 29 11:53:36 centos7.fenestros.loc nmbd[6825]: STATUS=daemon 'nmbd' finished starting up and ready to serve connections [root@centos7 ~]# ps aux | grep mb root 6793 0.0 0.3 410660 6164 ? Ss 11:53 0:00 /usr/sbin/smbd root 6794 0.0 0.1 404480 2880 ? S 11:53 0:00 /usr/sbin/smbd root 6795 0.0 0.1 404472 2600 ? S 11:53 0:00 /usr/sbin/smbd root 6796 0.0 0.1 410668 3512 ? S 11:53 0:00 /usr/sbin/smbd root 6825 0.0 0.1 337320 2716 ? Ss 11:53 0:00 /usr/sbin/nmbd root 7296 0.0 0.0 112648 960 pts/0 R+ 11:54 0:00 grep --color=auto mb
Testez ensuite le bon fonctionnement de Samba grâce à la commande smbclient :
[root@centos7 ~]# smbclient -U% -L localhost Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4] Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers IPC$ IPC IPC Service (Samba 4.4.4) Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4] Server Comment --------- ------- CENTOS7 Samba 4.4.4 Workgroup Master --------- ------- SAMBA CENTOS7
Les options de la commande smbclient sont nombreuses :
[root@centos7 ~]# smbclient --help Usage: smbclient service <password> -R, --name-resolve=NAME-RESOLVE-ORDER Use these name resolution services only -M, --message=HOST Send message -I, --ip-address=IP Use this IP to connect to -E, --stderr Write messages to stderr instead of stdout -L, --list=HOST Get a list of shares available on a host -m, --max-protocol=LEVEL Set the max protocol level -T, --tar=<c|x>IXFqgbNan Command line tar -D, --directory=DIR Start from directory -c, --command=STRING Execute semicolon separated commands -b, --send-buffer=BYTES Changes the transmit/send buffer -t, --timeout=SECONDS Changes the per-operation timeout -p, --port=PORT Port to connect to -g, --grepable Produce grepable output -B, --browse Browse SMB servers using DNS Help options: -?, --help Show this help message --usage Display brief usage message Common samba options: -d, --debuglevel=DEBUGLEVEL Set debug level -s, --configfile=CONFIGFILE Use alternate configuration file -l, --log-basename=LOGFILEBASE Base name for log files -V, --version Print version --option=name=value Set smb.conf option from command line Connection options: -O, --socket-options=SOCKETOPTIONS socket options to use -n, --netbiosname=NETBIOSNAME Primary netbios name -W, --workgroup=WORKGROUP Set the workgroup name -i, --scope=SCOPE Use this Netbios scope Authentication options: -U, --user=USERNAME Set the network username -N, --no-pass Don't ask for a password -k, --kerberos Use kerberos (active directory) authentication -A, --authentication-file=FILE Get the credentials from a file -S, --signing=on|off|required Set the client signing state -P, --machine-pass Use stored machine account password -e, --encrypt Encrypt SMB transport -C, --use-ccache Use the winbind ccache for authentication --pw-nt-hash The supplied password is the NT hash
Celles qui nous intéressent ici sont :
Vous allez maintenant créer le groupe staff, utilisé pour le partage Public:
[root@centos7 ~]# groupadd staff
Pour insérer des utilisateurs dans le groupe staff, ouvrez le fichier /etc/group et ajoutez tous les utilisateurs à qui vous souhaitez donner accès au partage public de samba au groupe staff.
[root@centos7 ~]# vi /etc/group [root@centos7 ~]# cat /etc/group root:x:0: ... trainee:x:1000:trainee vboxsf:x:983: staff:x:1001:trainee
Faites la même procédure pour le fichier /etc/gshadow :
[root@centos7 ~]# vi /etc/gshadow [root@centos7 ~]# cat /etc/gshadow root::: ... trainee:!!::trainee vboxsf:!:: staff:!::trainee
Afin de pouvoir permettre des connexions au serveur Samba, il faut créer le fichier /var/lib/samba/private/smbpasswd qui contiendra les utilisateurs autorisés.
En effet, le serveur Samba n'utilise pas le fichier de mots de passe de la machine Linux, à savoir le fichier /etc/passwd. Cependant, une fois le serveur Samba fonctionnel, nous pouvons stipuler que les deux fichiers soient synchronisés lors des modifications futures.
Modifiez la directive passdb backend du fichier /etc/samba/smb.conf afin d'utiliser le fichier /var/lib/samba/private/smbpasswd pour stocker les mots de passe samba :
[root@centos7 ~]# vi /etc/samba/smb.conf [root@centos7 ~]# cat /etc/samba/smb.conf # See smb.conf.example for a more detailed config file or # read the smb.conf manpage. # Run 'testparm' to verify the config is correct after # you modified it. [global] workgroup = SAMBA security = user #passdb backend = tdbsam passdb backend = smbpasswd printing = cups printcap name = cups load printers = yes cups options = raw [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = root create mask = 0664 directory mask = 0775
Le système de stockage des mots de passe peut être un des suivants :
Créez maintenant les mots de passe samba pour chaque utilisateur dans le fichier /var/lib/samba/private/smbpasswd :
[root@centos7 ~]# smbpasswd -a root New SMB password: Retype new SMB password: startsmbfilepwent_internal: file /var/lib/samba/private/smbpasswd did not exist. File successfully created. Added user root. [root@centos7 ~]# smbpasswd -a trainee New SMB password: Retype new SMB password: Added user trainee.
Consultez le fichier /var/lib/samba/private/smbpasswd. Vous devez constater une ligne pour chaque utilisateur. Chaque ligne doit comporter une chaîne de caractères alphanumérique :
[root@centos7 ~]# cat /var/lib/samba/private/smbpasswd root:0:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:E183384163AA4BFFAF24CC678CF19EAB:[U ]:LCT-597C6334: trainee:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:2A217A32BDE94A23B26A8EEA26C70874:[U ]:LCT-597C6343:
Créez ensuite un lien symbolique :
[root@centos7 ~]# ln -s /var/lib/samba/private/smbpasswd /etc/samba/smbpasswd
La commande pdbedit est utilisée pour la gestion de la base de données de SAMBA. Par exemple pour lister les utilisateurs de SAMBA :
[root@centos7 ~]# pdbedit -L root:0:root trainee:1000:trainee
Pour créer un compte SAMBA, l'utilisateur doit d'abord posséder un compte Unix :
[root@centos7 ~]# useradd sambauser
Il est ensuite possible d'utiliser la commande pdbedit pour créer l'utilisateur dans la base de données de SAMBA :
[root@centos7 ~]# useradd sambauser [root@centos7 ~]# pdbedit -a sambauser new password: retype new password: Unix username: sambauser NT username: Account Flags: [U ] User SID: S-1-5-21-3392617607-4065925175-2212523533-3002 Primary Group SID: S-1-5-21-3392617607-4065925175-2212523533-513 Full Name: Home Directory: \\centos7\sambauser HomeDir Drive: Logon Script: Profile Path: \\centos7\sambauser\profile Domain: CENTOS7 Account desc: Workstations: Munged dial: Logon time: 0 Logoff time: never Kickoff time: never Password last set: Tue, 15 Aug 2017 16:21:39 CEST Password can change: Tue, 15 Aug 2017 16:21:39 CEST Password must change: never Last bad password : 0 Bad password count : 0 Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Cette commande a donc ajouté l'utilisateur au fichier /var/lib/samba/private/smbpasswd :
[root@centos7 ~]# cat /var/lib/samba/private/smbpasswd root:0:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:E183384163AA4BFFAF24CC678CF19EAB:[U ]:LCT-5993021B: trainee:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:2A217A32BDE94A23B26A8EEA26C70874:[U ]:LCT-5993022B: sambauser:1001:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:C27F8C725297C4466C963B7F88906297:[U ]:LCT-59930373:
Pour visualiser les informations d'un utilisateur SAMBA existant, il convient d'utiliser les options -Lv :
[root@centos7 ~]# pdbedit -Lv sambauser Unix username: sambauser NT username: Account Flags: [U ] User SID: S-1-5-21-3392617607-4065925175-2212523533-3002 Primary Group SID: S-1-5-21-3392617607-4065925175-2212523533-513 Full Name: Home Directory: \\centos7\sambauser HomeDir Drive: Logon Script: Profile Path: \\centos7\sambauser\profile Domain: CENTOS7 Account desc: Workstations: Munged dial: Logon time: 0 Logoff time: never Kickoff time: never Password last set: Tue, 15 Aug 2017 16:21:39 CEST Password can change: Tue, 15 Aug 2017 16:21:39 CEST Password must change: never Last bad password : 0 Bad password count : 0 Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
La commande peut aussi être utiliser pour supprimer un utilisateur SAMBA :
[root@centos7 ~]# pdbedit -x sambauser [root@centos7 ~]# cat /var/lib/samba/private/smbpasswd root:0:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:E183384163AA4BFFAF24CC678CF19EAB:[U ]:LCT-5993021B: trainee:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:2A217A32BDE94A23B26A8EEA26C70874:[U ]:LCT-5993022B: [root@centos7 ~]# cat /etc/passwd | grep sambauser sambauser:x:1001:1002::/home/sambauser:/bin/bash
Ayant maintenant créé un fichier smbpasswd, il est le moment de terminer la configuration de votre serveur Samba.
Cette configuration est dictée par un seul et unique fichier – /etc/samba/smb.conf.
Avant de faire des manipulations, veillez à sauvegarder votre fichier smb.conf actuel :
[root@centos7 ~]# cp /etc/samba/smb.conf /etc/samba/smb.old
Examinez le fichier smb.conf suivant ainsi que le tableau récapitulatif des paramètres :
# Example d'un fichier smb.conf pour des partages par ressources # Toute ligne commencant par un # ou un ; est un commentaire et # n'est pas prise en compte lors de la lecture de ce fichier par # samba. N'oubliez pas de lancer la commande 'service smb restart' # lors de chaque changement et enregistrement de ce fichier. #======================= Section Globale ======================== [global] # 1. Options du nom du serveur: # Modifiez la ligne qui suit pour votre workgroup workgroup = WORKGROUP # Modifiez la ligne qui suit pour votre nom de machine. Par défaut sa valeur est la valeur de hostname netbios name = Machine01 server string = Samba Server %v # 2. Options d'impression : printcap name = cups load printers = yes printing = cups # 3. Options de journalisation : log file = /var/log/samba/log.%m max log size = 50 log level = 5 # 4. Options de sécurité : # Modifiez la ligne qui suit pour votre adresse reseau hosts allow = 192.168.1. 127. hosts deny = all security = user passdb backend = smbpasswd encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd unix password sync = Yes passwd program = /usr/bin/passwd %u passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully* # 5. Options du reseau: # Modifiez la ligne qui suit pour l'adresse IP de votre carte reseau interfaces = 192.168.1.22/255.255.255.0 # Modifiez la ligne qui suit à l'adresse de diffussion de votre reseau remote announce = 192.168.1.255 # 6.Options de resolutions de nom Netbios: name resolve order = wins lmhosts bcast host dns proxy = yes # 7. Options de nommage de fichiers: dos charset = 850 unix charset = ISO8859-1 #======================== Definitions des Partages ============================== [homes] comment = Repertoires Personnels browseable = no writable = yes [public] comment = Repertoire Public path = /home/samba/public write list = @staff read list = @staff writable = yes guest ok = no create mode = 0755 #Fin
Ce fichier est un exemple d'un smb.conf avec security = user. De cette façon chaque utilisateur ne verra que les partages auxquels il a un droit d'accès. En équivalence Windows™, ceci correspond à mettre en place un réseau poste-à-poste avec Windows™ NT4.0 Workstation.
Toute ligne commençant par # ou ; est un commentaire et n'est pas prise en compte lors de la lecture du fichier par Samba. Le fichier est divisé en deux parties – la section globale et la section partages.
L'exemple de smb.conf ci-dessus établira un niveau de sécurité par ressource. Dans ce cas, un utilisateur verra toutes les ressources partagées sur le serveur Linux dans le Voisinage Réseau Windows, mais il n'aura accès qu'aux ressources pour lesquelles il existe une autorisation explicite pour lui.
Afin de comprendre les paramètres dans le fichier précédent, consultez le tableau suivant :
Paramètre | Valeur Par Défaut | Description |
---|---|---|
Workgroup = | s/o | Le nom du groupe de travail |
Netbios name = | La valeur de hostname | Le nom NetBIOS du serveur |
Server string = | s/o | La description du serveur |
path = | s/o | Désigne le chemin du répertoire à partager |
comment = | s/o | Désigne le nom du partage visible dans le voisinage réseau Windows |
guest ok = yes | no | Si yes, le partage est en accès libre sans restrictions de mot de passe. |
guest account = | nobody | Le nom du compte d'accès libre. |
valid users = | tout utilisateur | Désigne une liste d'utilisateurs qui peuvent avoir accès à la ressource. La liste d'utilisateurs est séparé par des espaces. Chaque groupe commence avec @. Ex: valid users = user1 user2 @groupe3 |
printable = true | false | Partager un service d'impression |
writeable = yes | no | Désigne si oui ou non le droit d'écriture est accordé dans le répertoire concerné. |
write list = | tout utilisateur | Désigne la liste des utilisateurs qui peuvent écrire dans un répertoire. |
read list = | tout utilisateur | Désigne la liste des utilisateurs qui peuvent lire dans un répertoire. |
browseable = | yes | Désigne si oui ou non le partage sera visible par tous, y compris les utilisateurs non authentifiés. |
create mode = | 0744 | Désigne les droits maximum accordés à un fichier créés dans le répertoire concerné. |
create mask = | 0744 | Idem create mode =. |
directory mode = | 0755 | Désigne les droits maximum accordés à un répertoire créé dans la ressource. |
directory mask = | 0755 | Idem directory mode =. |
force create mode | s/o | Désigne les droits accordés à un fichier créés dans le répertoire concerné. |
force directory mode | s/o | Désigne les droits accordés à un répertoire créé dans la ressource. |
force group = | s/o | Impose un groupe propriétaire pour tout fichier créé dans le répertoire. |
hide dot files = | yes | Cache les fichiers cachés de Linux. |
hosts allow = | toute station | Liste d'adresses IP ayant accès à une ressource. |
hosts deny = | aucune | Liste d'adresses IP n'ayant pas accès à une ressource. |
max connections = | 0 | Désigne un nombre de connections illimités à la ressource concernée. Sinon spécifiez un nombre maximum de connexions. |
Log file = /chemin/log.%m | s/o | Désigne le chemin des logs. L'opérateur %m implique que chaque log aura le nom de la machine associé. Ex: log.station1, log.station2 etc. |
max log size = | s/o | La taille est à définir en Ko. C'est la taille maximale du fichier log. |
interfaces = | s/o | Désigne l'adresse IP de la carte réseau connecté au réseau Windows. A exprimer sous la forme N° IP/N° sous-masque. |
remote announce = | s/o | L'adresse de Broadcast du réseau, ici le 192.168.1.255. |
Notez que lors de chaque changement et enregistrement de ce fichier, il faut que smb relise le fichier.
Le fichier smb.conf utilise également des variables :
Variable | Description |
---|---|
%a | L'architecture du client (Samba, Windows 2000, Windows NT, Unknown |
%l | L'adresse IP du client |
%M | Le nom DNS du client |
%m | Le nom NetBIOS du client |
%u | L'identité de l'utilisateur |
%U | L'identité souhaité par l'utilisateur |
%H | Le répertoire de connexion de l'utilisateur |
%g | Le groupe principal de l'utilisateur |
%S | Le nom du partage |
%P | Le répertoire racine du partage |
%d | Le PID du process courant |
%h | Le nom DNS du serveur SAMBA |
%L | Le nom NetBIOS du serveur SAMBA |
%N | Idem %L |
%v | La version de SAMBA |
%T | La date et l'heure du système |
%var | La valeur de la variable var |
Créez donc le fichier smb.conf ci-dessous et placez-le dans le répertoire /etc/samba. Modifiez les directives hosts allow, interfaces et remote announce en fonction de votre adresse IP :
[global] workgroup = WORKGROUP netbios name = Machine01 server string = Samba Server %v printcap name = cups load printers = yes printing = cups log file = /var/log/samba/log.%m max log size = 50 log level = 5 hosts allow = 192.168.1. 127. hosts deny = all security = user passdb backend = smbpasswd encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd unix password sync = Yes passwd program = /usr/bin/passwd %u passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully* interfaces = 192.168.1.103/255.255.255.0 remote announce = 192.168.1.255 name resolve order = wins lmhosts bcast host dns proxy = yes dos charset = 850 unix charset = ISO8859-1 [homes] comment = Repertoires Personnels browseable = no writable = yes [public] comment = Repertoire Public path = /home/samba/public write list = @staff read list = @staff writable = yes guest ok = no create mode = 0755
Rechargez le fichier de configuration smb.conf :
[root@centos7 ~]# systemctl reload smb
Créez maintenant le répertoire /home/samba/public :
[root@centos7 ~]# mkdir -p /home/samba/public
Ensuite, afin que chaque utilisateur puisse écrire dans le répertoire public mais supprimer uniquement ses propres fichiers et répertoires, il faut modifier les permissions pour le répertoire /home/samba/public :
[root@centos7 ~]# chmod 1777 /home/samba/public
Vous pouvez tester votre fichier smb.conf avec la commande testparm :
[root@centos7 ~]# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[homes]" Processing section "[public]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions # Global parameters [global] dos charset = 850 interfaces = 192.168.1.103/255.255.255.0 netbios name = MACHINE01 server string = Samba Server %v unix charset = ISO8859-1 log file = /var/log/samba/log.%m max log size = 50 remote announce = 192.168.1.255 printcap name = cups name resolve order = wins lmhosts bcast host passdb backend = smbpasswd passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully* passwd program = /usr/bin/passwd %u security = USER smb passwd file = /etc/samba/smbpasswd unix password sync = Yes idmap config * : backend = tdb hosts allow = 192.168.1. 127. hosts deny = all [homes] comment = Repertoires Personnels browseable = No read only = No [public] comment = Repertoire Public path = /home/samba/public create mask = 0755 read list = @staff read only = No write list = @staff
Pour tester votre configuration :
La directive printing du fichier /etc/samba/smb.conf définit le type de spooleur Unix afin d'utiliser les commandes du service d'impression. Les valeurs possibles de cette directive sont :
Dans l'utilisation de Linux en tant que serveur samba, le type de spooleur utilisé est principalement cups.
Le logiciel Common Unix Printing System est un système de gestion des impressions conçu pour Unix.
Cups utilise le protocole IPP sur les ports udp/631 et tcp/631.
Ce protocole :
Cups peut aussi utiliser les deux protocoles suivants :
cupsd est le daemon principal du système CUPS. Quand cupsd traite une impression, il transmet les données à un filtre en fonction du modèle d'imprimante. Après traitement par le filtre, cupsd transmet le résultat à un backend qui se charge de l'impression. Les échanges entre cupsd et ces programmes se font via des répertoires de spools et des tubes.
Le principal fichier concerné par CUPS est :
Le fichier de configuration de CUPS est /etc/cups/cupsd.conf. Dans ce fichier on peut trouver :
[root@centos7 ~]# cat /etc/cups/cupsd.conf MaxLogSize 0 # # "$Id: cupsd.conf.in 7888 2008-08-29 21:16:56Z mike $" # # Sample configuration file for the CUPS scheduler. See "man cupsd.conf" for a # complete description of this file. # # Log general information in error_log - change "warn" to "debug" # for troubleshooting... LogLevel warn # Only listen for connections from the local machine. Listen localhost:631 Listen /var/run/cups/cups.sock # Show shared printers on the local network. Browsing On BrowseLocalProtocols dnssd # Default authentication type, when authentication is required... DefaultAuthType Basic # Web interface setting... WebInterface Yes # Restrict access to the server... <Location /> Order allow,deny </Location> # Restrict access to the admin pages... <Location /admin> Order allow,deny </Location> # Restrict access to configuration files... <Location /admin/conf> AuthType Default Require user @SYSTEM Order allow,deny </Location> # Set the default printer/job policies... <Policy default> # Job/subscription privacy... JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default # Job-related operations must be done by the owner or an administrator... <Limit Create-Job Print-Job Print-URI Validate-Job> Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document> Require user @OWNER @SYSTEM Order deny,allow </Limit> # All administration operations require an administrator to authenticate... <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices> AuthType Default Require user @SYSTEM Order deny,allow </Limit> # All printer operations require a printer operator to authenticate... <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs> AuthType Default Require user @SYSTEM Order deny,allow </Limit> # Only the owner or an administrator can cancel or authenticate a job... <Limit Cancel-Job CUPS-Authenticate-Job> Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> # Set the authenticated printer/job policies... <Policy authenticated> # Job/subscription privacy... JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default # Job-related operations must be done by the owner or an administrator... <Limit Create-Job Print-Job Print-URI Validate-Job> AuthType Default Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> # All administration operations require an administrator to authenticate... <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default> AuthType Default Require user @SYSTEM Order deny,allow </Limit> # All printer operations require a printer operator to authenticate... <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs> AuthType Default Require user @SYSTEM Order deny,allow </Limit> # Only the owner or an administrator can cancel or authenticate a job... <Limit Cancel-Job CUPS-Authenticate-Job> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> # # End of "$Id: cupsd.conf.in 7888 2008-08-29 21:16:56Z mike $". #
Les filtres disponibles au système CUPS se trouvent dans le répertoire /usr/lib/cups/filter :
[root@centos7 ~]# ls /usr/lib/cups/filter bannertopdf gstoraster imagetoraster rastertodymo rastertopwg commandtocanon gziptoany pdftoijs rastertoepson textonly commandtoepson hpcups pdftopdf rastertoescpx texttopaps commandtoescpx hpcupsfax pdftops rastertogutenprint.5.2 texttopdf commandtopclx hplipjs pdftoraster rastertohp texttops commandtops imagetopdf pstopdf rastertolabel gstopxl imagetops pstops rastertopclx
Les Backends disponibles au système CUPS se trouvent dans le répertoire /usr/lib/cups/backend :
[root@centos7 ~]# ls /usr/lib/cups/backend dnssd http ipp lpd parallel snmp usb failover https ipps ncp serial socket
La liste des backends reconnus par CUPS peut être obtenue en saisissant la commande suivante :
[root@centos7 ~]# lpinfo -v network lpd network http network socket network https network ipp network ipps
Il y a un type de backend par liaison locale d'imprimante (usb, série, parallèle). Il peut y avoir aussi un backend par type de protocole réseau :
Backend | Description |
---|---|
IPP | Client IPP |
LPD | Client LPD |
SMB | Client SMB |
Socket | Client JetDirect sur port tcp/9100 |
Pap/cap | Client AppleTalk |
Les journaux de CUPS se trouvent dans /var/log/cups :
[root@centos7 ~]# ls -l /var/log/cups total 8 -rw-------. 1 root lp 1394 Oct 29 10:04 access_log -rw-------. 1 root lp 1740 Oct 26 15:41 access_log-20151026 -rw-------. 1 root lp 0 Mar 8 2015 error_log -rw-------. 1 root lp 0 Mar 8 2015 page_log
La commande suivante liste les imprimantes connues de CUPS :
[root@centos7 ~]# lpinfo -m | more drv:///hp/hpijs.drv/apollo-2100-hpijs.ppd Apollo 2100 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2100.ppd Apollo 2100, hpcups 3.13.7 drv:///hp/hpijs.drv/apollo-2150-hpijs.ppd Apollo 2150 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2150.ppd Apollo 2150, hpcups 3.13.7 drv:///hp/hpijs.drv/apollo-2200-hpijs.ppd Apollo 2200 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2200.ppd Apollo 2200, hpcups 3.13.7 drv:///hp/hpijs.drv/apollo-2500-hpijs.ppd Apollo 2500 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2500.ppd Apollo 2500, hpcups 3.13.7 drv:///hp/hpijs.drv/apollo-2600-hpijs.ppd Apollo 2600 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2600.ppd Apollo 2600, hpcups 3.13.7 drv:///hp/hpijs.drv/apollo-2650-hpijs.ppd Apollo 2650 hpijs, 3.13.7 drv:///hp/hpcups.drv/apollo-2650.ppd Apollo 2650, hpcups 3.13.7 gutenprint.5.2://pcl-apollo-p2100/expert Apollo P-2100 - CUPS+Gutenprint v5.2.9 gutenprint.5.2://pcl-apollo-p2100/simple Apollo P-2100 - CUPS+Gutenprint v5.2.9 Simplified gutenprint.5.2://pcl-apollo-p2150/expert Apollo P-2150 - CUPS+Gutenprint v5.2.9 gutenprint.5.2://pcl-apollo-p2150/simple Apollo P-2150 - CUPS+Gutenprint v5.2.9 Simplified gutenprint.5.2://pcl-apollo-p2200/expert Apollo P-2200 - CUPS+Gutenprint v5.2.9 gutenprint.5.2://pcl-apollo-p2200/simple Apollo P-2200 - CUPS+Gutenprint v5.2.9 Simplified gutenprint.5.2://pcl-apollo-p2250/expert Apollo P-2250 - CUPS+Gutenprint v5.2.9 gutenprint.5.2://pcl-apollo-p2250/simple Apollo P-2250 - CUPS+Gutenprint v5.2.9 --More--
Le serveur CUPS est administré en ligne de commande par l'utilisation d'une ou de plusieurs des commandes suivantes :
Commande | Description |
---|---|
lpadmin | Principale commande d'administration pour ajouter, supprimer et modifier des files d'attente |
accept | Autorise le dépôt de requêtes dans un spool |
reject | Interdit le dépôt de requêtes dans un spool |
cupsenable | Autorise le traitement des requêtes dans un spool |
cupsdisable | Interdit le traitement des requêtes dans un spool |
lpstat | Liste des travaux en attente |
cancel | Supprime des requêtes |
lpmove | Déplace des travaux en attente d'un spool à un autre |
lpinfo | Affiche la liste des filtres ou backends disponibles |
lppasswd | Gère les comptes et les mots de passe pour l'accès web |
Pour consulter la liste des files d'attente, il convient d'utiliser donc la commande lpstat :
[root@centos7 ~]# lpstat -t scheduler is running no system default destination lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added.
Créez maintenant une file d'attente sans pilote. Les imprimantes sans pilote utilisent le mode raw :
[root@centos7 ~]# lpadmin -p imp1 -v socket://localhost:12000 -m raw
Les options de cette commande sont les suivantes :
Options | Description |
---|---|
-p | Le nom de la file |
-v | L'imprimante physique ou réseau sous forme URL |
-m | Le modèle à utiliser (un fichier ayant une extension ppd qui identifie l'imprimante) |
Les types de URL possible sont :
URL | Description |
---|---|
file:/chemin/fichier | Impression dans un fichier |
http://serveur:631/ipp/port1 | Impression via http |
lpd://serveur/queue | Impression via LPD |
ipp://serveur:631/printers/queue | Impression via IPP |
smb://workgroup/serveur/nompartage | Impression via SMB |
socket://serveur | Impression via JetDirect |
serial:/dev/ttyS0?baud=1200+bits=8+parity=none+flow=none | Impression via port série |
parallel:/dev/lp0 | Impression via port parallèle |
Vérifiez la création de la file d'attente :
[root@centos7 ~]# lpstat -t scheduler is running no system default destination device for imp1: socket://localhost:12000 imp1 not accepting requests since Thu 29 Oct 2015 10:06:57 AM CET - reason unknown printer imp1 disabled since Thu 29 Oct 2015 10:06:57 AM CET - reason unknown
Il est maintenant possible d'activer l'imprimante grâce aux commandes accept et enable :
[root@centos7 ~]# accept imp1 [root@centos7 ~]# lpstat -t scheduler is running no system default destination device for imp1: socket://localhost:12000 imp1 accepting requests since Thu 29 Oct 2015 10:06:57 AM CET printer imp1 disabled since Thu 29 Oct 2015 10:06:57 AM CET - reason unknown [root@centos7 ~]# cupsenable imp1 [root@centos7 ~]# lpstat -t scheduler is running no system default destination device for imp1: socket://localhost:12000 imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET
Important : Notez que les deux commandes accept et cupsenable ont leurs opposées : reject et cupsdisable.
Pour nommer une imprimante en tant que la destination par défaut, il convient d'utiliser la commande lpadmin avec l'option -d :
[root@centos7 ~]# lpadmin -d imp1 [root@centos7 ~]# lpstat -t scheduler is running system default destination: imp1 device for imp1: socket://localhost:12000 imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET
Vous allez mainteant créer une fille d'attente pour une imprimante HP Color LaserJet Series PCL 6 utilisant le fichier pxlcolor.ppd, appelée Imprimante1 et étant connectée au port parallèle :
[root@centos7 ~]# lpadmin -p Imprimante1 -E -v parallel:/dev/lp0 -m pxlcolor.ppd [root@centos7 ~]# lpstat -t scheduler is running system default destination: imp1 device for imp1: socket://localhost:12000 device for Imprimante1: parallel:/dev/lp0 imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET Imprimante1 accepting requests since Thu 29 Oct 2015 10:09:31 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET printer Imprimante1 is idle. enabled since Thu 29 Oct 2015 10:09:31 AM CET
Important : Notez que l'option -E permet de combiner les commandes accept et cupsenable avec lpadmin.
Sous RHEL/CentOS la file d'attente physique pour cette imprimante existe déjà :
[root@centos7 ~]# ls -l /dev/lp0 crw-rw----. 1 root lp 6, 0 Oct 28 09:40 /dev/lp0
Testez maintenant votre imprimante fictive :
[root@centos7 ~]# echo "Test Printer File" > /tmp/test.print [root@centos7 ~]# lpadmin -d Imprimante1 [root@centos7 ~]# lpstat -t scheduler is running system default destination: Imprimante1 device for imp1: socket://localhost:12000 device for Imprimante1: parallel:/dev/lp0 imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET Imprimante1 accepting requests since Thu 29 Oct 2015 10:09:31 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET printer Imprimante1 is idle. enabled since Thu 29 Oct 2015 10:09:31 AM CET [root@centos7 ~]# lp /tmp/test.print request id is Imprimante1-1 (1 file(s))
Important : Notez que l'impression a eu lieu et la requête s'appelle Imprimante1-1.
Créez maintenant une deuxième file d'attente Imprimante2 et saisissez la commande lpstat -t. Vous devez obtenir un résultat similaire à celui-ci :
[root@centos7 ~]# lpadmin -p Imprimante2 -E -v parallel:/dev/lp1 -m pxlcolor.ppd [root@centos7 ~]# lpstat -t scheduler is running system default destination: Imprimante1 device for imp1: socket://localhost:12000 device for Imprimante1: parallel:/dev/lp0 device for Imprimante2: parallel:/dev/lp1 imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET Imprimante1 accepting requests since Thu 29 Oct 2015 10:15:42 AM CET Imprimante2 accepting requests since Thu 29 Oct 2015 10:29:52 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET printer Imprimante1 now printing Imprimante1-1. enabled since Thu 29 Oct 2015 10:15:42 AM CET Printer not connected; will retry in 30 seconds. printer Imprimante2 is idle. enabled since Thu 29 Oct 2015 10:29:52 AM CET Imprimante1-1 root 1024 Thu 29 Oct 2015 10:15:42 AM CET
Une classe est un ensemble ordonné d'imprimantes. Les requêtes envoyées à la classe sont imprimées sur la première imprimante disponible.
Pour créer une classe il convient d'utiliser la commande lpadmin avec l'option -c suivie par le nom de la classe à créer :
[root@centos7 ~]# lpadmin -p Imprimante1 -c classe1 [root@centos7 ~]# lpadmin -p Imprimante2 -c classe1
Vérifiez la création de la classe :
[root@centos7 ~]# lpstat -t scheduler is running system default destination: Imprimante1 members of class classe1: Imprimante1 Imprimante2 device for classe1: ///dev/null device for imp1: socket://localhost:12000 device for Imprimante1: parallel:/dev/lp0 device for Imprimante2: parallel:/dev/lp1 classe1 not accepting requests since Thu 29 Oct 2015 10:30:45 AM CET - reason unknown imp1 accepting requests since Thu 29 Oct 2015 10:08:13 AM CET Imprimante1 accepting requests since Thu 29 Oct 2015 10:15:42 AM CET Imprimante2 accepting requests since Thu 29 Oct 2015 10:29:52 AM CET printer classe1 disabled since Thu 29 Oct 2015 10:30:45 AM CET - reason unknown printer imp1 is idle. enabled since Thu 29 Oct 2015 10:08:13 AM CET printer Imprimante1 now printing Imprimante1-1. enabled since Thu 29 Oct 2015 10:15:42 AM CET Printer not connected; will retry in 30 seconds. printer Imprimante2 is idle. enabled since Thu 29 Oct 2015 10:29:52 AM CET Imprimante1-1 root 1024 Thu 29 Oct 2015 10:15:42 AM CET
La configuration globale des files d'attente se trouve dans le fichier /etc/cups/printers.conf :
[root@centos7 ~]# cat /etc/cups/printers.conf # Printer configuration file for CUPS v1.6.3 # Written by cupsd on 2015-10-29 10:30 # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING <Printer imp1> UUID urn:uuid:8de75f5f-0ef2-3bc2-46cd-72696519155a Info imp1 DeviceURI socket://localhost:12000 State Idle StateTime 1446109693 Type 4 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer> <DefaultPrinter Imprimante1> UUID urn:uuid:07682275-f74a-3fa2-5ad5-4311207ee125 Info Imprimante1 MakeModel HP Color LaserJet Series PCL 6 CUPS DeviceURI parallel:/dev/lp0 State Idle StateTime 1446110142 Type 8400972 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer> <Printer Imprimante2> UUID urn:uuid:1fadf858-f631-3f4b-56d6-9acc408ab75c Info Imprimante2 MakeModel HP Color LaserJet Series PCL 6 CUPS DeviceURI parallel:/dev/lp1 State Idle StateTime 1446110992 Type 8400972 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer>
La configuration globale des classes se trouve dans le fichier /etc/cups/classes.conf :
[root@centos7 ~]# cat /etc/cups/classes.conf # Class configuration file for CUPS v1.6.3 # Written by cupsd on 2015-10-29 10:31 # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING <Class classe1> UUID urn:uuid:dc222765-63c6-394e-4fb3-d203c1475019 Info classe1 State Stopped StateTime 1446111045 Accepting No Shared Yes JobSheets none none Printer Imprimante1 Printer Imprimante2 QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy retry-current-job </Class>
Pour annuler l'impression il convient d'utiliser la commande cancel:
[root@centos7 ~]# lpstat Imprimante1-1 root 1024 Thu 29 Oct 2015 10:15:42 AM CET [root@centos7 ~]# cancel imprimante1-1 [root@centos7 ~]# lpstat [root@centos7 ~]#
La commande lpmove permet de déplacer tous les jobs d'une file à une autre.
Déclarez l'imprimante imp1 comme étant l'imprimante par défault :
[root@centos7 ~]# lpadmin -d imp1
Créez ensuite une nouvelle impression :
[root@centos7 ~]# lp /tmp/test.print request id is imp1-2 (1 file(s)) [root@centos7 ~]# lpstat imp1-2 root 1024 Thu 29 Oct 2015 10:37:41 AM CET
Déplacer ce job vers la classe1 :
[root@centos7 ~]# lpmove imp1 classe1 [root@centos7 ~]# lpstat classe1-2 root 1024 Thu 29 Oct 2015 10:37:41 AM CET
Pour retirer une file d'une classe, il convient d'utiliser la commande lpadmin :
[root@centos7 ~]# lpadmin -p Imprimante1 -r classe1 [root@centos7 ~]# lpadmin -p Imprimante2 -r classe1 [root@centos7 ~]# lpstat -t scheduler is running system default destination: imp1 device for imp1: socket://localhost:12000 device for Imprimante1: parallel:/dev/lp0 device for Imprimante2: parallel:/dev/lp1 imp1 accepting requests since Thu 29 Oct 2015 10:38:22 AM CET Imprimante1 accepting requests since Thu 29 Oct 2015 10:36:49 AM CET Imprimante2 accepting requests since Thu 29 Oct 2015 10:29:52 AM CET printer imp1 is idle. enabled since Thu 29 Oct 2015 10:38:22 AM CET The printer is not responding. printer Imprimante1 is idle. enabled since Thu 29 Oct 2015 10:36:49 AM CET Printer not connected; will retry in 30 seconds. printer Imprimante2 is idle. enabled since Thu 29 Oct 2015 10:29:52 AM CET
Important : Notez que la classe est automatiquement supprimée quand elle est vide.
Pour supprimer les files créées il convient de nouveau à utiliser la commande lpadmin :
[root@centos7 ~]# lpadmin -x Imprimante1 [root@centos7 ~]# lpadmin -x Imprimante2 [root@centos7 ~]# lpadmin -x imp1 [root@centos7 ~]# lpstat -t scheduler is running no system default destination lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added.
CUPS peut également être administré en utilisant l'interface Web sur le port 631/tcp. L'interface de votre machine virtuelle est disponible à partir de votre machine hôte via une redirection de ports à l'adresse http://localhost:2631.
A faire : Lancez l'interface Web. Re-créez les mêmes imprimantes et la même classe.
Le fichier /etc/printcap contient la définition des imprimantes locales :
[root@centos7 ~]# cat /etc/printcap # This file was automatically generated by cupsd(8) from the # /etc/cups/printers.conf file. All changes to this file # will be lost. classe1|classe1:rm=centos7.fenestros.loc:rp=classe1: imp1|imp1:rm=centos7.fenestros.loc:rp=imp1: Imprimante1|Imprimante1:rm=centos7.fenestros.loc:rp=Imprimante1: Imprimante2|Imprimante2:rm=centos7.fenestros.loc:rp=Imprimante2:
Afin de permettre samba à utiliser les imprimantes précédemment créées, il est nécessaire d'ajouter 3 sections au fichier /etc/samba/smb.conf :
[Imprimante1] path = /var/spool/samba/imprimante1 printer = Imprimante1 printable = yes browseable = yes public = yes guest ok = yes writable = no [print$] comment = drivers pour imprimantes path = /etc/samba/printer_drivers browseable = yes guest ok = yes read only = yes write list = root
Créez ensuite les répertoires de spool :
[root@centos7 ~]# mkdir /var/spool/samba/imprimante1 [root@centos7 ~]# mkdir /var/spool/samba/imprimante2
ainsi que le répertoire pour les pilotes :
[root@centos7 ~]# mkdir /etc/samba/printer_drivers
Redémarrez les services smb et nmb :
[root@centos7 ~]# systemctl restart smb [root@centos7 ~]# systemctl restart nmb
Testez ensuite le bon fonctionnement de Samba grâce à la commande smbclient :
[root@centos7 ~]# smbclient -U% -L localhost Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.4.4] Sharename Type Comment --------- ---- ------- public Disk Repertoire Public Imprimante1 Printer print$ Disk drivers pour imprimantes IPC$ IPC IPC Service (Samba Server 4.4.4) Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.4.4] Server Comment --------- ------- Workgroup Master --------- ------- SAMBA CENTOS7
Le partage print$ est utilisé pour stocker les pilotes postscript génériques pour nos imprimantes et destinés aux clients Windows™.
Afin de mettre en place ces pilotes, il convient de les télécharger :
[root@centos7 ~]# wget http://unixmaniax.fr/download/cups_drivers_win32.zip --2017-07-30 06:21:58-- http://unixmaniax.fr/download/cups_drivers_win32.zip Resolving unixmaniax.fr (unixmaniax.fr)... 213.186.33.19 Connecting to unixmaniax.fr (unixmaniax.fr)|213.186.33.19|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 636872 (622K) [application/zip] Saving to: ‘cups_drivers_win32.zip’ 100%[=======================================================================================>] 636,872 1.54MB/s in 0.4s 2017-07-30 06:22:04 (1.54 MB/s) - ‘cups_drivers_win32.zip’ saved [636872/636872] [root@centos7 ~]# wget http://unixmaniax.fr/download/cups_drivers_win64.zip --2017-07-30 06:22:11-- http://unixmaniax.fr/download/cups_drivers_win64.zip Resolving unixmaniax.fr (unixmaniax.fr)... 213.186.33.19 Connecting to unixmaniax.fr (unixmaniax.fr)|213.186.33.19|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1108000 (1.1M) [application/zip] Saving to: ‘cups_drivers_win64.zip’ 100%[=======================================================================================>] 1,108,000 3.02MB/s in 0.4s 2017-07-30 06:22:12 (3.02 MB/s) - ‘cups_drivers_win64.zip’ saved [1108000/1108000]
Créez ensuite le répertoire /usr/share/cups/drivers/x64 :
[root@centos7 ~]# mkdir -p /usr/share/cups/drivers/x64
Déplacez les fichiers *.zip téléchargés et décompressez-les :
[root@centos7 ~]# mv cups_drivers_win32.zip /usr/share/cups/drivers/ [root@centos7 ~]# mv cups_drivers_win64.zip /usr/share/cups/drivers/x64/ [root@centos7 ~]# cd /usr/share/cups/drivers/ [root@centos7 drivers]# unzip cups_drivers_win32.zip Archive: cups_drivers_win32.zip inflating: cups6.inf inflating: cups6.ini inflating: cups6.ppd inflating: cupsps6.dll inflating: cupsui6.dll inflating: ps5ui.dll inflating: pscript.hlp inflating: pscript.ntf inflating: pscript5.dll [root@centos7 drivers]# ls -l total 2056 -rwxrwxrwx. 1 root root 760 Dec 9 2010 cups6.inf -rwxrwxrwx. 1 root root 67 Dec 9 2010 cups6.ini -rwxrwxrwx. 1 root root 9529 Dec 9 2010 cups6.ppd -rw-r--r--. 1 root root 636872 Aug 30 2013 cups_drivers_win32.zip -rwxrwxrwx. 1 root root 12568 Dec 9 2010 cupsps6.dll -rwxrwxrwx. 1 root root 13672 Dec 9 2010 cupsui6.dll -rwxrwxrwx. 1 root root 129024 Aug 28 2013 ps5ui.dll -rwxrwxrwx. 1 root root 455168 Aug 28 2013 pscript5.dll -rwxrwxrwx. 1 root root 26038 Aug 28 2013 pscript.hlp -rwxrwxrwx. 1 root root 792644 Aug 28 2013 pscript.ntf drwxr-xr-x. 2 root root 35 Jul 30 06:29 x64 [root@centos7 drivers]# cd x64 [root@centos7 x64]# unzip cups_drivers_win64.zip Archive: cups_drivers_win64.zip inflating: cups6.inf inflating: cups6.ini inflating: cups6.ppd inflating: cupsps6.dll inflating: cupsui6.dll inflating: ps5ui.dll inflating: pscript.hlp inflating: pscript.ntf inflating: pscript5.dll [root@centos7 x64]# ls -l total 3652 -rwxrwxrwx. 1 root root 760 Jul 26 2011 cups6.inf -rwxrwxrwx. 1 root root 67 Jul 26 2011 cups6.ini -rwxrwxrwx. 1 root root 9529 Jul 26 2011 cups6.ppd -rw-r--r--. 1 root root 1108000 Aug 30 2013 cups_drivers_win64.zip -rwxrwxrwx. 1 root root 12568 Jul 26 2011 cupsps6.dll -rwxrwxrwx. 1 root root 13672 Jul 26 2011 cupsui6.dll -rwxrwxrwx. 1 root root 850432 Aug 28 2013 ps5ui.dll -rwxrwxrwx. 1 root root 628736 Aug 28 2013 pscript5.dll -rwxrwxrwx. 1 root root 26038 Aug 28 2013 pscript.hlp -rwxrwxrwx. 1 root root 1062696 Aug 28 2013 pscript.ntf
Afin d'installer ces pilotes dans le répertoire /etc/samba/printer_drivers définit par la section print$ du fichier /etc/samba/smb.conf, il convient d'utiliser la commande suivante :
[root@centos7 ~]# cupsaddsmb -v -a
A l'issu de ce processus, vous constaterez la présence des pilotes dans le répertoire /etc/samba/printer_drivers :
[root@centos7 x64]# cd /etc/samba/printer_drivers [root@centos7 printer_drivers]# ls IA64 W32ALPHA W32MIPS W32PPC W32X86 WIN40 x64 [root@centos7 printer_drivers]# cd x64 [root@centos7 x64]# ls 3 classe1.ppd cups6.ini cupsps6.dll cupsui6.dll ps5ui.dll pscript5.dll pscript.hlp pscript.ntf
Pour tester votre configuration :
Important : Pour effectuer les exercices, vous aurez besoin d'avoir accès à un serveur controleur de domaine Windows™ 2008. Si vous êtes stagiaire en salle, votre formateur vous remettra une machine virtuelle Windows™ 2008 Standard.
Notre but ici est de faire d'un serveur samba un serveur membre d'un domaine AD sur un serveur Windows™ 2008 Standard. La procédure a été également testée avec un serveur Windows™ 2008 r2 Enterprise.
Commencez par créer un réseau NAT dans VirtualBox :
Fichier > Paramètres > Réseau > + > NatNetwork > OK
Important : Supprimez votre machine virtuelle CentOS_7 et importez une machine virtuelle vierge. Mettez la machine virtuelle dans le réseau NatNetwork.
Désactivez SELINUX afin de ne pas avoir des erreurs de ce dernier :
[root@centos7 /]# setenforce permissive [root@centos7 /]# getenforce Permissive
Editez ensuite le fichier /etc/sysconfig/selinux ainsi :
[root@centos7 /]# vi /etc/sysconfig/selinux [root@centos7 /]# cat /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
Afin d'éviter les problèmes liés au pare-feu arrêtez le service firewalld :
[root@centos7 ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2017-07-30 14:03:15 CEST; 1min 38s ago Docs: man:firewalld(1) Main PID: 576 (firewalld) CGroup: /system.slice/firewalld.service └─576 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Jul 30 14:03:08 centos7.fenestros.loc systemd[1]: Starting firewalld - dynamic firewall daemon... Jul 30 14:03:15 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. [root@centos7 ~]# systemctl stop firewalld.service [root@centos7 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@centos7 ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) Jul 30 14:03:08 centos7.fenestros.loc systemd[1]: Starting firewalld - dynamic firewall daemon... Jul 30 14:03:15 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. Jul 30 14:05:09 centos7.fenestros.loc systemd[1]: Stopping firewalld - dynamic firewall daemon... Jul 30 14:05:10 centos7.fenestros.loc systemd[1]: Stopped firewalld - dynamic firewall daemon.
Modifiez ensuite le fichier /etc/hosts pour définir votre hostname et votre adresse IP :
[root@centos7 ~]# vi /etc/hosts [root@centos7 ~]# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.0.2.5 centos7.fenestros.loc
Important: Modifiez l'adresse IP dans votre fichier /etc/hosts en fonction de votre adresse IP réelle.
Maintenant installez le paquet samba-swat :
[root@centos7 ~]# yum install samba-swat Loaded plugins: fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast adobe-linux-x86_64 | 2.9 kB 00:00:00 base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): adobe-linux-x86_64/primary_db | 2.7 kB 00:00:00 (2/3): updates/7/x86_64/primary_db | 7.8 MB 00:00:03 (3/3): extras/7/x86_64/primary_db | 191 kB 00:00:03 Determining fastest mirrors * base: centos.crazyfrogs.org * extras: mirrors.ircam.fr * updates: mirrors.ircam.fr Resolving Dependencies --> Running transaction check ---> Package samba.x86_64 0:4.4.4-14.el7_3 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================= Installing: samba x86_64 4.4.4-14.el7_3 updates 610 k Transaction Summary ======================================================================================================================================= Install 1 Package Total download size: 610 k Installed size: 1.8 M Is this ok [y/d/N]: y
Les paquets ainsi installés sont :
[root@centos7 ~]# rpm -qa | grep samba samba-client-libs-4.4.4-14.el7_3.x86_64 samba-libs-4.4.4-14.el7_3.x86_64 samba-common-tools-4.4.4-14.el7_3.x86_64 samba-common-libs-4.4.4-14.el7_3.x86_64 samba-client-4.4.4-14.el7_3.x86_64 samba-common-4.4.4-14.el7_3.noarch samba-4.4.4-14.el7_3.x86_64
Les deamons smb et nmb ne sont pas démarrés :
[root@centos7 ~]# systemctl status smb ● smb.service - Samba SMB Daemon Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@centos7 ~]# systemctl status nmb ● nmb.service - Samba NMB Daemon Loaded: loaded (/usr/lib/systemd/system/nmb.service; disabled; vendor preset: disabled) Active: inactive (dead)
Notez que le démarrage automatique de Samba n'est pas configuré. Configurez donc le démarrage automatique de Samba :
[root@centos7 ~]# systemctl enable smb Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service. [root@centos7 ~]# systemctl enable nmb Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
Vérifiez que votre samba a été compilé avec le support pour LDAP, Kerberos, AD et Winbind :
[root@centos7 ~]# /usr/sbin/smbd -b | grep LDAP HAVE_LDAP_H HAVE_LDAP HAVE_LDAP_ADD_RESULT_ENTRY HAVE_LDAP_INIT HAVE_LDAP_INITIALIZE HAVE_LDAP_INIT_FD HAVE_LDAP_OPT_SOCKBUF HAVE_LDAP_SASL_WRAPPING HAVE_LDAP_SET_REBIND_PROC HAVE_LIBLDAP LDAP_DEPRECATED LDAP_SET_REBIND_PROC_ARGS [root@centos7 ~]# /usr/sbin/smbd -b | grep KRB HAVE_GSSAPI_GSSAPI_KRB5_H HAVE_KRB5_H HAVE_KRB5_LOCATE_PLUGIN_H HAVE_ADDRTYPE_IN_KRB5_ADDRESS HAVE_DECL_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE HAVE_DECL_KRB5_GET_CREDENTIALS_FOR_USER HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT HAVE_GSS_KRB5_IMPORT_CRED HAVE_GSS_MECH_KRB5 HAVE_INITIALIZE_KRB5_ERROR_TABLE HAVE_KRB5 HAVE_KRB5_AUTH_CON_SETUSERUSERKEY HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE HAVE_KRB5_BUILD_PRINCIPAL_ALLOC_VA HAVE_KRB5_CC_RETRIEVE_CRED HAVE_KRB5_C_MAKE_CHECKSUM HAVE_KRB5_C_STRING_TO_KEY HAVE_KRB5_C_VERIFY_CHECKSUM HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER HAVE_KRB5_ENCRYPT_BLOCK HAVE_KRB5_ENCTYPE_TO_STRING HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG HAVE_KRB5_FREE_CHECKSUM_CONTENTS HAVE_KRB5_FREE_DATA_CONTENTS HAVE_KRB5_FREE_HOST_REALM HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS HAVE_KRB5_FREE_UNPARSED_NAME HAVE_KRB5_FWD_TGT_CREDS HAVE_KRB5_GET_CREDENTIALS_FOR_USER HAVE_KRB5_GET_HOST_REALM HAVE_KRB5_GET_INIT_CREDS_KEYTAB HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC HAVE_KRB5_GET_INIT_CREDS_OPT_FREE HAVE_KRB5_GET_PERMITTED_ENCTYPES HAVE_KRB5_GET_PROFILE HAVE_KRB5_GET_PROMPT_TYPES HAVE_KRB5_GET_RENEWED_CREDS HAVE_KRB5_KEYTAB_ENTRY_KEY HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM HAVE_KRB5_KT_FREE_ENTRY HAVE_KRB5_MK_REQ_EXTENDED HAVE_KRB5_PRINCIPAL2SALT HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM HAVE_KRB5_PRINC_COMPONENT HAVE_KRB5_PRINC_REALM HAVE_KRB5_SET_DEFAULT_TGS_ENCTYPES HAVE_KRB5_SET_DEFAULT_TGS_KTYPES HAVE_MAGIC_IN_KRB5_ADDRESS HAVE_TICKET_POINTER_IN_KRB5_AP_REQ KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT USING_SYSTEM_KRB5 [root@centos7 ~]# /usr/sbin/smbd -b | grep ADS WITH_ADS [root@centos7 ~]# /usr/sbin/smbd -b | grep WINBIND WITH_WINBIND
La machine virtuelle Windows™ Server 2008 a été configurée de la façon suivante :
Important : Importez la machine virtuelle Windows™ 2008 Server. Mettez la machine virtuelle server dans le réseau NatNetwork et démarrez-le.
Dans la machine virtuelle CentOS 7, éditez le fichier /etc/krb5.conf :
[root@centos7 ~]# vi /etc/krb5.conf [root@centos7 ~]# cat /etc/krb5.conf [logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = FENESTROS.LOC dns_lookup_realm = false dns_lookup_kdc = false ticket_lifetime = 24h renew_lifetime = 7d forwardable = yes [realms] FENESTROS.LOC = { kdc = server.fenestros.loc:88 admin_server = server.fenestros.loc:749 default_domain = fenestros.loc } [domain_realm] .fenestros.loc = FENESTROS.LOC fenestros.loc = FENESTROS.LOC [appdefaults] pam = { debug = false ticket_lifetime = 36000 renew_lifetime = 36000 forwardable = true krb4_convert = false }
Important - Les directives kdc et admin_server dans la secion [realms] doivent être modifiées par rapport au FQDN de votre serveur Windows ™ 2008. Pour plus d'information sur le fichier /etc/krb5.conf, consultez le manuel krb5.conf.
Éditez ensuite le fichier /etc/hosts afin d'établir la correspondance entre l'adresse IP du serveur Windows™ et son FQDN :
[root@centos7 ~]# vi /etc/hosts [root@centos7 ~]# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.0.2.5 centos7.fenestros.loc 10.0.2.200 server.fenestros.loc
Important : La dernière ligne de ce fichier doit être modifiée en fonction du FQDN et de l'adresse IP de votre serveur Windows™ 2008.
Testez ensuite la connexion au domaine afin d'obtenir un ticket ( ou jeton ) kerberos :
[root@centos7 ~]# kinit Administrateur Password for Administrateur@FENESTROS.LOC: Fenestr0$
Important - La commande kinit sert à obtenir et mettre en cache un ticket ( ou jeton ) kerberos. Pour plus d'informations concernant la commande kinit, consultez la page du manuel : man kinit.
Visualisez ensuite le ticket :
[root@centos7 ~]# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: Administrateur@FENESTROS.LOC Valid starting Expires Service principal 30/07/17 14:58:54 31/07/17 00:58:54 krbtgt/FENESTROS.LOC@FENESTROS.LOC renew until 06/08/17 14:58:50
Important - La commande klist sert à afficher les tickets ( ou jetons ) kerberos dans le cache. Pour plus d'informations concernant la commande klist, consultez la page du manuel : man klist.
Éditez ensuite le fichier /etc/samba/smb.conf :
[root@centos7 ~]# vi /etc/samba/smb.conf [root@centos7 ~]# cat /etc/samba/smb.conf [global] workgroup = FENESTROS realm = FENESTROS.LOC preferred master = no server string = Serveur Samba security = ADS encrypt passwords = yes log level = 3 log file = /var/log/samba/%m max log size = 50 interfaces = 127.0.0.1 enp0s3 bind interfaces only = true winbind separator = @ idmap config *:backend = tdb idmap config *:range = 40001-75000 idmap config FENESTROS:backend = idmap_rid:FENESTROS= 40001-75000 idmap config FENESTROS:schema_mode = rfc2307 idmap config FENESTROS:range = 500-40000
Les directives les plus importantes dans ce fichier sont :
Ajoutez ensuite la ligne suivante à votre fichier /etc/security/limits.conf :
* - nofile 16384
Cette modification est nécessaire pour les clients Windows™ 7. L'étoile représente une entrée par défaut. Le mot clef nofile indique le nombre de fichiers maximum ouverts dont la valeur est fixée à 16384. Cette valeur est en effet celle des serveurs Windows™. Sans cette modification la commande testparm retourne une ligne du type :
rlimit_max: rlimit_max (8192) below minimum Windows limit (16384)
ou
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
En fait, le serveur samba modifie la valeur automatiquement pour éviter des erreurs out of handles lors de certaines opérations de copie de fichiers par les clients Windows™ 7. Cependant, il est conseillé de faire la modification comme même.
Vous obtiendrez alors :
[root@centos7 ~]# vi /etc/security/limits.conf [root@centos7 ~]# cat /etc/security/limits.conf # /etc/security/limits.conf # #This file sets the resource limits for the users logged in via PAM. #It does not affect resource limits of the system services. # #Also note that configuration files in /etc/security/limits.d directory, #which are read in alphabetical order, override the settings in this #file in case the domain is the same or more specific. #That means for example that setting a limit for wildcard domain here #can be overriden with a wildcard setting in a config file in the #subdirectory, but a user specific setting here can be overriden only #with a user specific setting in the subdirectory. # #Each line describes a limit for a user in the form: # #<domain> <type> <item> <value> # #Where: #<domain> can be: # - a user name # - a group name, with @group syntax # - the wildcard *, for default entry # - the wildcard %, can be also used with %group syntax, # for maxlogin limit # #<type> can have the two values: # - "soft" for enforcing the soft limits # - "hard" for enforcing hard limits # #<item> can be one of the following: # - core - limits the core file size (KB) # - data - max data size (KB) # - fsize - maximum filesize (KB) # - memlock - max locked-in-memory address space (KB) # - nofile - max number of open file descriptors # - rss - max resident set size (KB) # - stack - max stack size (KB) # - cpu - max CPU time (MIN) # - nproc - max number of processes # - as - address space limit (KB) # - maxlogins - max number of logins for this user # - maxsyslogins - max number of logins on the system # - priority - the priority to run user process with # - locks - max number of file locks the user can hold # - sigpending - max number of pending signals # - msgqueue - max memory used by POSIX message queues (bytes) # - nice - max nice priority allowed to raise to values: [-20, 19] # - rtprio - max realtime priority # #<domain> <type> <item> <value> # #* soft core 0 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #@student - maxlogins 4 * - nofile 16384 # End of file
Vérifiez votre fichier smb.conf :
[root@centos7 ~]# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Loaded services file OK. Server role: ROLE_DOMAIN_MEMBER Press enter to see a dump of your service definitions # Global parameters [global] bind interfaces only = Yes interfaces = 127.0.0.1 enp0s3 realm = FENESTROS.LOC server string = Serveur Samba workgroup = FENESTROS preferred master = No log file = /var/log/samba/%m max log size = 50 security = ADS winbind separator = @ idmap config fenestros:range = 500-40000 idmap config fenestros:schema_mode = rfc2307 idmap config fenestros:backend = idmap_rid:FENESTROS= 40001-75000 idmap config *:range = 40001-75000 idmap config * : backend = tdb
Démarrez le service samba :
[root@centos7 ~]# systemctl start smb
Mettez le serveur samba dans le domaine :
[root@centos7 ~]# net rpc join -S SERVEUR_FQDN -I SERVEUR_IP -U administrateur%SERVEUR_MDP [Entrée]
Par exemple :
[root@centos7 ~]# net rpc join -S server.fenestros.loc -I 10.0.2.200 -U administrateur Enter administrateur's password:Fenestr0$ Using short domain name -- FENESTROS Joined 'CENTOS7' to realm 'fenestros.loc'
Arrêtez ensuite le serveur samba :
[root@centos7 ~]# systemctl stop smb
Faire une sauvegarde de votre fichier /etc/nsswitch.conf :
[root@centos7 ~]# cp /etc/nsswitch.conf /etc/nsswitch.conf.old
Editez ensuite le fichier /etc/nsswitch.conf et modifiez uniquement les lignes suivantes :
passwd: compat winbind group: compat winbind shadow: compat hosts: files dns wins networks: files dns protocols: db files services: db files ethers: db files rpc: db files
[root@centos7 ~]# vi /etc/nsswitch.conf [root@centos7 ~]# cat /etc/nsswitch.conf # # /etc/nsswitch.conf # # An example Name Service Switch config file. This file should be # sorted with the most-used services at the beginning. # # The entry '[NOTFOUND=return]' means that the search for an # entry should stop if the search in the previous entry turned # up nothing. Note that if the search failed due to some other reason # (like no NIS server responding) then the search continues with the # next entry. # # Valid entries include: # # nisplus Use NIS+ (NIS version 3) # nis Use NIS (NIS version 2), also called YP # dns Use DNS (Domain Name Service) # files Use the local files # db Use the local database (.db) files # compat Use NIS on compat mode # hesiod Use Hesiod for user lookups # [NOTFOUND=return] Stop searching if not found so far # # To use db, put the "db" in front of "files" for entries you want to be # looked up first in the databases # # Example: #passwd: db files nisplus nis #shadow: db files nisplus nis #group: db files nisplus nis passwd: compat winbind group: compat winbind shadow: compat #passwd: files sss #shadow: files sss #group: files sss #initgroups: files #hosts: db files nisplus nis dns #hosts: files dns myhostname hosts: files dns wins # Example - obey only what nisplus tells us... #services: nisplus [NOTFOUND=return] files #networks: nisplus [NOTFOUND=return] files #protocols: nisplus [NOTFOUND=return] files #rpc: nisplus [NOTFOUND=return] files #ethers: nisplus [NOTFOUND=return] files #netmasks: nisplus [NOTFOUND=return] files bootparams: nisplus [NOTFOUND=return] files networks: files dns protocols: db files services: db files ethers: db files rpc: db files #ethers: files netmasks: files #networks: files #protocols: files #rpc: files #services: files sss netgroup: files sss publickey: nisplus automount: files sss aliases: files nisplus
Installez le service winbind ainsi que les clients :
[root@centos7 ~]# yum install samba-winbind samba-winbind-clients
Démarrez ensuite le service winbind :
[root@centos7 ~]# systemctl status winbind ● winbind.service - Samba Winbind Daemon Loaded: loaded (/usr/lib/systemd/system/winbind.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@centos7 ~]# systemctl enable winbind Created symlink from /etc/systemd/system/multi-user.target.wants/winbind.service to /usr/lib/systemd/system/winbind.service. [root@centos7 ~]# systemctl start winbind [root@centos7 ~]# systemctl status winbind ● winbind.service - Samba Winbind Daemon Loaded: loaded (/usr/lib/systemd/system/winbind.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2017-07-30 15:20:58 CEST; 2s ago Main PID: 8619 (winbindd) Status: "winbindd: ready to serve connections..." CGroup: /system.slice/winbind.service ├─8619 /usr/sbin/winbindd └─8620 /usr/sbin/winbindd Jul 30 15:20:57 centos7.fenestros.loc systemd[1]: Starting Samba Winbind Daemon... Jul 30 15:20:58 centos7.fenestros.loc winbindd[8619]: [2017/07/30 15:20:58.167888, 0] ../source3/winbindd/winbindd_cache.c:32...cache) Jul 30 15:20:58 centos7.fenestros.loc winbindd[8619]: initialize_winbindd_cache: clearing cache and re-creating with version number 2 Jul 30 15:20:58 centos7.fenestros.loc winbindd[8619]: [2017/07/30 15:20:58.174374, 0] ../lib/util/become_daemon.c:124(daemon_ready) Jul 30 15:20:58 centos7.fenestros.loc systemd[1]: Started Samba Winbind Daemon. Jul 30 15:20:58 centos7.fenestros.loc winbindd[8619]: STATUS=daemon 'winbindd' finished starting up and ready to serve connections Jul 30 15:20:58 centos7.fenestros.loc winbindd[8620]: [2017/07/30 15:20:58.221519, 0] ../source3/libsmb/cliconnect.c:1895(cli..._send) Jul 30 15:20:58 centos7.fenestros.loc winbindd[8620]: Kinit for FENESTROS.LOC to access cifs/server.fenestros.loc@FENESTROS....tabase Hint: Some lines were ellipsized, use -l to show in full.
Ainsi que le service samba :
[root@centos7 ~]# systemctl start smb
Vérifiez ensuite que le service winbind fonctionne en interrogeant le serveur 2008 :
[root@centos7 ~]# wbinfo -u FENESTROS@administrateur FENESTROS@invité FENESTROS@krbtgt [root@centos7 ~]# wbinfo -g FENESTROS@ordinateurs du domaine FENESTROS@contrôleurs de domaine FENESTROS@administrateurs du schéma FENESTROS@administrateurs de l’entreprise FENESTROS@éditeurs de certificats FENESTROS@admins du domaine FENESTROS@utilisateurs du domaine FENESTROS@invités du domaine FENESTROS@propriétaires créateurs de la stratégie de groupe FENESTROS@serveurs ras et ias FENESTROS@groupe de réplication dont le mot de passe rodc est autorisé FENESTROS@groupe de réplication dont le mot de passe rodc est refusé FENESTROS@contrôleurs de domaine en lecture seule FENESTROS@contrôleurs de domaine d’entreprise en lecture seule FENESTROS@dnsadmins FENESTROS@dnsupdateproxy
Dernièrement, renseignez-vous sur le serveur 2008 :
[root@centos7 ~]# net ads info LDAP server: 10.0.2.200 LDAP server name: server.fenestros.loc Realm: FENESTROS.LOC Bind Path: dc=FENESTROS,dc=LOC LDAP port: 389 Server time: Sun, 30 Jul 2017 15:24:49 CEST KDC server: 10.0.2.200 Server time offset: 0 Last machine account password change: Sun, 30 Jul 2017 15:12:07 CEST
Modifiez maintenant votre fichier /etc/samba/smb.conf :
[global] workgroup = FENESTROS password server = server.fenestros.loc realm = FENESTROS.LOC security = ADS idmap config *:backend = tdb idmap config *:range = 10000-50000 idmap config FENESTROS:backend = idmap_rid:FENESTROS=10000-50000 idmap config FENESTROS:schema_mode = rfc2307 idmap config FENESTROS:range = 500-40000 winbind separator = @ template homedir = /home/%D/%U template shell = /bin/bash winbind use default domain = true winbind offline logon = true local master = no preferred master = no os level = 0 server string = Serveur Samba encrypt passwords = yes log level = 3 log file = /var/log/samba/%m max log size = 50 interfaces = 127.0.0.1 enp0s3 bind interfaces only = true winbind cache time = 15 winbind enum users = yes winbind enum groups = yes winbind nss info = rfc2307 obey pam restrictions = yes allow trusted domains = no
Les directives les plus importantes dans ce fichier sont :
Redémarrez les services winbind et samba :
[root@centos7 ~]# systemctl restart winbind [root@centos7 ~]# systemctl restart smb
Vérifiez maintenant que les mots de passe sont authentifiés par le serveur Windows™ 2008 :
[root@centos7 ~]# getent passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:997:995:User for polkitd:/:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin colord:x:996:993:User for colord:/var/lib/colord:/sbin/nologin libstoragemgmt:x:995:992:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin setroubleshoot:x:994:991::/var/lib/setroubleshoot:/sbin/nologin rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin chrony:x:993:990::/var/lib/chrony:/sbin/nologin unbound:x:992:989:Unbound DNS resolver:/etc/unbound:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin geoclue:x:991:988:User for geoclue:/var/lib/geoclue:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin sssd:x:990:987:User for sssd:/:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin gdm:x:42:42::/var/lib/gdm:/sbin/nologin gnome-initial-setup:x:989:984::/run/gnome-initial-setup/:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin trainee:x:1000:1000:trainee:/home/trainee:/bin/bash vboxadd:x:988:1::/var/run/vboxadd:/bin/false administrateur:*:40003:40006:Administrateur:/home/FENESTROS/administrateur:/bin/bash invité:*:40001:40005:Invité:/home/FENESTROS/invité:/bin/bash krbtgt:*:40002:40006:krbtgt:/home/FENESTROS/krbtgt:/bin/bash
Créez maintenant le répertoire /home/FENESTROS qui sera utilisé pour contenir les répertoires personnels des utilisateurs de l'AD :
[root@centos7 ~]# mkdir /home/FENESTROS
Accordez le permissions adéquates :
[root@centos7 ~]# chmod 777 /home/FENESTROS
Ajoutez la ligne suivante au fichier /etc/pam.d/system-auth :
session required pam_oddjob_mkhomedir.so skel=/etc/skel/ umask=0022
pam_oddjob_mkhomedir est utilisé par le système afin de créer le répertoire personnel d'un utilisateur autorisé si le répertoire n'existe pas. Si le répertoire personnel n'existe pas et pam_oddjob_mkhomedir ne fonctionne pas, la connexion de l'utilisateur sera rejeté.
Vous obtiendrez :
[root@centos7 ~]# vi /etc/pam.d/system-auth [root@centos7 ~]# cat /etc/pam.d/system-auth #%PAM-1.0 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. auth required pam_env.so auth sufficient pam_fprintd.so auth sufficient pam_unix.so nullok try_first_pass auth requisite pam_succeed_if.so uid >= 1000 quiet_success auth required pam_deny.so account required pam_unix.so account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 1000 quiet account required pam_permit.so password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok password required pam_deny.so session optional pam_keyinit.so revoke session required pam_limits.so session required pam_oddjob_mkhomedir.so skel=/etc/skel/ umask=0022 -session optional pam_systemd.so session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid session required pam_unix.so
Redémarrez le service winbind et démarrez le service oddjobd :
[root@centos7 ~]# systemctl restart winbind [root@centos7 ~]# systemctl status oddjobd ● oddjobd.service - privileged operations for unprivileged applications Loaded: loaded (/usr/lib/systemd/system/oddjobd.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@centos7 ~]# systemctl enable oddjobd Created symlink from /etc/systemd/system/multi-user.target.wants/oddjobd.service to /usr/lib/systemd/system/oddjobd.service. [root@centos7 ~]# systemctl start oddjobd [root@centos7 ~]# systemctl status oddjobd ● oddjobd.service - privileged operations for unprivileged applications Loaded: loaded (/usr/lib/systemd/system/oddjobd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2017-07-31 13:45:56 CEST; 10s ago Main PID: 28054 (oddjobd) CGroup: /system.slice/oddjobd.service └─28054 /usr/sbin/oddjobd -n -p /var/run/oddjobd.pid -t 300 Jul 31 13:45:56 centos7.fenestros.loc systemd[1]: Started privileged operations for unprivileged applications. Jul 31 13:45:56 centos7.fenestros.loc systemd[1]: Starting privileged operations for unprivileged applications...
Important : Supprimez votre machine virtuelle CentOS 7 et importez une machine virtuelle vierge.
Rappelez-vous que Samba4 apporte les nouveautés suivantes :
Pouyr commencer :
Désactivez SELINUX afin de ne pas avoir des erreurs de ce dernier :
[root@centos7 /]# setenforce permissive [root@centos7 /]# getenforce Permissive
Editez ensuite le fichier /etc/sysconfig/selinux ainsi :
[root@centos7 /]# vi /etc/sysconfig/selinux [root@centos7 /]# cat /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
Afin d'éviter les problèmes liés au pare-feu arrêtez le service firewalld :
[root@centos7 ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2017-07-31 15:21:08 CEST; 3min 30s ago Docs: man:firewalld(1) Main PID: 633 (firewalld) CGroup: /system.slice/firewalld.service └─633 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Jul 31 15:21:01 centos7.fenestros.loc systemd[1]: Starting firewalld - dynami... Jul 31 15:21:08 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic... Hint: Some lines were ellipsized, use -l to show in full. [root@centos7 ~]# systemctl stop firewalld.service [root@centos7 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
Créez un profile en IP fixe, activez-le, ajoutez le DNS et re-démarrez le service NetworkManager.service :
[root@centos7 ~]# nmcli connection add con-name ip_fixe ifname enp0s3 type ethernet ip4 10.0.2.6/24 gw4 10.0.2.2 Connection 'ip_fixe' (7c801069-d035-4f2f-8496-a96385b83bcd) successfully added. [root@centos7 ~]# nmcli connection up ip_fixe Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1) [root@centos7 ~]# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 [root@centos7 ~]# systemctl restart NetworkManager.service
Modifiez ensuite le fichier /etc/hosts pour définir votre hostname et votre adresse IP :
[root@centos7 ~]# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.0.2.6 centos7.fenestros.loc
A Faire - Modifiez l'adresse IP dans votre fichier /etc/hosts en fonction de votre adresse IP réelle.
Attention - La version de Samba4 dans les dépôts de CentOS 7 ne contient pas le binaire samba-tool pour provisionner l'AD Voir cet article. Pour cette raison, nous allons compiler samba à partir des sources.
Pour commencer, ajoutez le dépôt EPEL :
[root@centos7 ~]# yum install epel-release -y Loaded plugins: fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast adobe-linux-x86_64 | 2.9 kB 00:00 base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/3): adobe-linux-x86_64/primary_db | 2.7 kB 00:00 (2/3): extras/7/x86_64/primary_db | 191 kB 00:00 (3/3): updates/7/x86_64/primary_db | 7.8 MB 00:02 Determining fastest mirrors * base: ftp.ciril.fr * extras: ftp.ciril.fr * updates: centos.mirror.ate.info Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: epel-release noarch 7-9 extras 14 k Transaction Summary ================================================================================ Install 1 Package Total download size: 14 k Installed size: 24 k Downloading packages: epel-release-7-9.noarch.rpm | 14 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-9.noarch 1/1 Verifying : epel-release-7-9.noarch 1/1 Installed: epel-release.noarch 0:7-9 Complete!
Installez maintenant les outils nécessaires pour compiler samba4 :
[root@centos7 ~]# yum install perl gcc libacl-devel libblkid-devel gnutls-devel readline-devel python-devel gdb pkgconfig krb5-workstation zlib-devel setroubleshoot-server libaio-devel setroubleshoot-plugins policycoreutils-python libsemanage-python setools-libs-python setools-libs popt-devel libpcap-devel sqlite-devel libidn-devel libxml2-devel libacl-devel libsepol-devel libattr-devel keyutils-libs-devel cyrus-sasl-devel cups-devel bind-utils libxslt docbook-style-xsl openldap-devel pam-devel bzip2 vim wget Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.ciril.fr * epel: pkg.adfinis-sygroup.ch * extras: ftp.ciril.fr * updates: centos.mirror.ate.info Package 4:perl-5.16.3-291.el7.x86_64 already installed and latest version Package gcc-4.8.5-11.el7.x86_64 already installed and latest version Package gdb-7.6.1-94.el7.x86_64 already installed and latest version Package 1:pkgconfig-0.27.1-4.el7.x86_64 already installed and latest version Package krb5-workstation-1.14.1-27.el7_3.x86_64 already installed and latest version Package setroubleshoot-server-3.2.27.2-3.el7.x86_64 already installed and latest version Package setroubleshoot-plugins-3.0.64-2.1.el7.noarch already installed and latest version Package policycoreutils-python-2.5-11.el7_3.x86_64 already installed and latest version Package libsemanage-python-2.5-5.1.el7_3.x86_64 already installed and latest version No package setools-libs-python available. Package setools-libs-3.3.8-1.1.el7.x86_64 already installed and latest version Package libxslt-1.1.28-5.el7.x86_64 already installed and latest version Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version Package 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 already installed and latest version Package wget-1.14-13.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package bind-utils.x86_64 32:9.9.4-38.el7_3.3 will be updated ---> Package bind-utils.x86_64 32:9.9.4-50.el7_3.1 will be an update --> Processing Dependency: bind-libs = 32:9.9.4-50.el7_3.1 for package: 32:bind-utils-9.9.4-50.el7_3.1.x86_64 ---> Package cups-devel.x86_64 1:1.6.3-26.el7 will be installed --> Processing Dependency: openssl-devel for package: 1:cups-devel-1.6.3-26.el7.x86_64 --> Processing Dependency: krb5-devel for package: 1:cups-devel-1.6.3-26.el7.x86_64 ---> Package cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 will be installed --> Processing Dependency: cyrus-sasl(x86-64) = 2.1.26-20.el7_2 for package: cyrus-sasl-devel-2.1.26-20.el7_2.x86_64 ---> Package docbook-style-xsl.noarch 0:1.78.1-3.el7 will be installed --> Processing Dependency: docbook-dtd-xml for package: docbook-style-xsl-1.78.1-3.el7.noarch ---> Package gnutls-devel.x86_64 0:3.3.24-1.el7 will be installed --> Processing Dependency: gnutls-dane(x86-64) = 3.3.24-1.el7 for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: gnutls-c++(x86-64) = 3.3.24-1.el7 for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: pkgconfig(p11-kit-1) for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: pkgconfig(nettle) for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: pkgconfig(libtasn1) for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: pkgconfig(hogweed) for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: libgnutlsxx.so.28()(64bit) for package: gnutls-devel-3.3.24-1.el7.x86_64 --> Processing Dependency: libgnutls-dane.so.0()(64bit) for package: gnutls-devel-3.3.24-1.el7.x86_64 ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package libacl-devel.x86_64 0:2.2.51-12.el7 will be installed ---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed ---> Package libattr-devel.x86_64 0:2.4.46-12.el7 will be installed ---> Package libblkid-devel.x86_64 0:2.23.2-33.el7_3.2 will be installed --> Processing Dependency: pkgconfig(uuid) for package: libblkid-devel-2.23.2-33.el7_3.2.x86_64 ---> Package libidn-devel.x86_64 0:1.28-4.el7 will be installed ---> Package libpcap-devel.x86_64 14:1.5.3-8.el7 will be installed ---> Package libsepol-devel.x86_64 0:2.5-6.el7 will be installed ---> Package libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 will be installed --> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64 ---> Package openldap-devel.x86_64 0:2.4.40-13.el7 will be installed ---> Package pam-devel.x86_64 0:1.1.8-18.el7 will be installed ---> Package popt-devel.x86_64 0:1.13-16.el7 will be installed ---> Package python-devel.x86_64 0:2.7.5-48.el7 will be installed ---> Package readline-devel.x86_64 0:6.2-9.el7 will be installed --> Processing Dependency: ncurses-devel for package: readline-devel-6.2-9.el7.x86_64 ---> Package sqlite-devel.x86_64 0:3.7.17-8.el7 will be installed ---> Package zlib-devel.x86_64 0:1.2.7-17.el7 will be installed --> Running transaction check ---> Package bind-libs.x86_64 32:9.9.4-38.el7_3.3 will be updated ---> Package bind-libs.x86_64 32:9.9.4-50.el7_3.1 will be an update --> Processing Dependency: bind-license = 32:9.9.4-50.el7_3.1 for package: 32:bind-libs-9.9.4-50.el7_3.1.x86_64 ---> Package cyrus-sasl.x86_64 0:2.1.26-20.el7_2 will be installed ---> Package docbook-dtds.noarch 0:1.0-60.el7 will be installed --> Processing Dependency: sgml-common for package: docbook-dtds-1.0-60.el7.noarch ---> Package gnutls-c++.x86_64 0:3.3.24-1.el7 will be installed ---> Package gnutls-dane.x86_64 0:3.3.24-1.el7 will be installed ---> Package krb5-devel.x86_64 0:1.14.1-27.el7_3 will be installed --> Processing Dependency: libverto-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64 ---> Package libtasn1-devel.x86_64 0:3.8-3.el7 will be installed ---> Package libuuid-devel.x86_64 0:2.23.2-33.el7_3.2 will be installed ---> Package ncurses-devel.x86_64 0:5.9-13.20130511.el7 will be installed ---> Package nettle-devel.x86_64 0:2.7.1-8.el7 will be installed --> Processing Dependency: gmp-devel(x86-64) for package: nettle-devel-2.7.1-8.el7.x86_64 ---> Package openssl-devel.x86_64 1:1.0.1e-60.el7_3.1 will be installed ---> Package p11-kit-devel.x86_64 0:0.20.7-3.el7 will be installed ---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed --> Running transaction check ---> Package bind-license.noarch 32:9.9.4-38.el7_3.3 will be updated --> Processing Dependency: bind-license = 32:9.9.4-38.el7_3.3 for package: 32:bind-libs-lite-9.9.4-38.el7_3.3.x86_64 ---> Package bind-license.noarch 32:9.9.4-50.el7_3.1 will be an update ---> Package gmp-devel.x86_64 1:6.0.0-12.el7_1 will be installed ---> Package libcom_err-devel.x86_64 0:1.42.9-9.el7 will be installed ---> Package libselinux-devel.x86_64 0:2.5-6.el7 will be installed --> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-6.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed ---> Package sgml-common.noarch 0:0.6.3-39.el7 will be installed --> Running transaction check ---> Package bind-libs-lite.x86_64 32:9.9.4-38.el7_3.3 will be updated ---> Package bind-libs-lite.x86_64 32:9.9.4-50.el7_3.1 will be an update ---> Package pcre-devel.x86_64 0:8.32-15.el7_2.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: cups-devel x86_64 1:1.6.3-26.el7 base 130 k cyrus-sasl-devel x86_64 2.1.26-20.el7_2 base 310 k docbook-style-xsl noarch 1.78.1-3.el7 base 2.0 M gnutls-devel x86_64 3.3.24-1.el7 base 1.4 M keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k libacl-devel x86_64 2.2.51-12.el7 base 71 k libaio-devel x86_64 0.3.109-13.el7 base 13 k libattr-devel x86_64 2.4.46-12.el7 base 35 k libblkid-devel x86_64 2.23.2-33.el7_3.2 updates 73 k libidn-devel x86_64 1.28-4.el7 base 124 k libpcap-devel x86_64 14:1.5.3-8.el7 base 117 k libsepol-devel x86_64 2.5-6.el7 base 74 k libxml2-devel x86_64 2.9.1-6.el7_2.3 base 1.0 M openldap-devel x86_64 2.4.40-13.el7 base 800 k pam-devel x86_64 1.1.8-18.el7 base 184 k popt-devel x86_64 1.13-16.el7 base 22 k python-devel x86_64 2.7.5-48.el7 base 393 k readline-devel x86_64 6.2-9.el7 base 138 k sqlite-devel x86_64 3.7.17-8.el7 base 104 k zlib-devel x86_64 1.2.7-17.el7 base 50 k Updating: bind-utils x86_64 32:9.9.4-50.el7_3.1 updates 202 k Installing for dependencies: cyrus-sasl x86_64 2.1.26-20.el7_2 base 88 k docbook-dtds noarch 1.0-60.el7 base 226 k gmp-devel x86_64 1:6.0.0-12.el7_1 base 181 k gnutls-c++ x86_64 3.3.24-1.el7 base 32 k gnutls-dane x86_64 3.3.24-1.el7 base 33 k krb5-devel x86_64 1.14.1-27.el7_3 updates 651 k libcom_err-devel x86_64 1.42.9-9.el7 base 31 k libselinux-devel x86_64 2.5-6.el7 base 186 k libtasn1-devel x86_64 3.8-3.el7 base 70 k libuuid-devel x86_64 2.23.2-33.el7_3.2 updates 85 k libverto-devel x86_64 0.2.5-4.el7 base 12 k ncurses-devel x86_64 5.9-13.20130511.el7 base 713 k nettle-devel x86_64 2.7.1-8.el7 base 471 k openssl-devel x86_64 1:1.0.1e-60.el7_3.1 updates 1.2 M p11-kit-devel x86_64 0.20.7-3.el7 base 22 k pcre-devel x86_64 8.32-15.el7_2.1 base 479 k sgml-common noarch 0.6.3-39.el7 base 55 k xz-devel x86_64 5.2.2-1.el7 base 46 k Updating for dependencies: bind-libs x86_64 32:9.9.4-50.el7_3.1 updates 1.0 M bind-libs-lite x86_64 32:9.9.4-50.el7_3.1 updates 730 k bind-license noarch 32:9.9.4-50.el7_3.1 updates 83 k Transaction Summary ================================================================================ Install 20 Packages (+18 Dependent packages) Upgrade 1 Package (+ 3 Dependent packages) Total download size: 14 M Is this ok [y/d/N]: y
Téléchargez maintenant samba4 :
[root@centos7 ~]# cd /tmp [root@centos7 tmp]# wget https://download.samba.org/pub/samba/stable/samba-4.6.6.tar.gz --2017-07-31 16:17:27-- https://download.samba.org/pub/samba/stable/samba-4.6.6.tar.gz Resolving download.samba.org (download.samba.org)... 144.76.82.156, 2a01:4f8:192:486::443:2 Connecting to download.samba.org (download.samba.org)|144.76.82.156|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 21120791 (20M) [application/gzip] Saving to: ‘samba-4.6.6.tar.gz’ 100%[=============================================================================================>] 21,120,791 167KB/s in 77s 2017-07-31 16:18:45 (268 KB/s) - ‘samba-4.6.6.tar.gz’ saved [21120791/21120791]
Décompressez et désarchivez le fichier :
[root@centos7 tmp]# tar -zxvf samba-4.6.6.tar.gz
Compilez samba4 :
[root@centos7 tmp]# cd samba-4.6.6 [root@centos7 samba-4.6.6]# ./configure --enable-debug --enable-selftest --with-ads --with-systemd --with-winbind [root@centos7 samba-4.6.6]# make && make install
Créez maintenant le fichier /etc/systemd/system/samba.service :
[root@centos7 samba-4.6.6]# vi /etc/systemd/system/samba.service [root@centos7 samba-4.6.6]# cat /etc/systemd/system/samba.service [Unit] Description= Samba 4 Active Directory After=syslog.target After=network.target [Service] Type=forking PIDFile=/usr/local/samba/var/run/samba.pid ExecStart=/usr/local/samba/sbin/samba [Install] WantedBy=multi-user.target
Activez le service :
[root@centos7 samba-4.6.6]# systemctl enable samba Created symlink from /etc/systemd/system/multi-user.target.wants/samba.service to /etc/systemd/system/samba.service.
Vérifiez le démarrage automatique de Samba :
[root@centos7 samba-4.6.6]# systemctl status samba ● samba.service - Samba 4 Active Directory Loaded: loaded (/etc/systemd/system/samba.service; enabled; vendor preset: disabled) Active: inactive (dead)
L'arboresence de samba4 se trouve dans /usr/local/samba :
[root@centos7 samba-4.6.6]# cd /usr/local/samba [root@centos7 samba]# ls bin etc include lib lib64 libexec private sbin share var
Les binaires de samba4 se trouvent dans /usr/local/samba/bin :
[root@centos7 samba]# cd bin [root@centos7 bin]# ls -l total 22988 -rwxr-xr-x. 1 root root 249120 Jul 31 16:45 cifsdd -rwxr-xr-x. 1 root root 35680 Jul 31 16:46 dbwrap_tool -rwxr-xr-x. 1 root root 68576 Jul 31 16:45 eventlogadm -rwxr-xr-x. 1 root root 4619 Jul 31 16:34 findsmb -rwxr-xr-x. 1 root root 357488 Jul 31 16:45 gentest -rwxr-xr-x. 1 root root 23744 Jul 31 16:45 ldbadd -rwxr-xr-x. 1 root root 17912 Jul 31 16:45 ldbdel -rwxr-xr-x. 1 root root 24688 Jul 31 16:45 ldbedit -rwxr-xr-x. 1 root root 28088 Jul 31 16:45 ldbmodify -rwxr-xr-x. 1 root root 16528 Jul 31 16:45 ldbrename -rwxr-xr-x. 1 root root 26720 Jul 31 16:45 ldbsearch -rwxr-xr-x. 1 root root 227520 Jul 31 16:45 locktest -rwxr-xr-x. 1 root root 221520 Jul 31 16:45 masktest -rwxr-xr-x. 1 root root 18288 Jul 31 16:46 mvxattr -rwxr-xr-x. 1 root root 236488 Jul 31 16:45 ndrdump -rwxr-xr-x. 1 root root 1916488 Jul 31 16:47 net -rwxr-xr-x. 1 root root 228856 Jul 31 16:45 nmblookup -rwxr-xr-x. 1 root root 139576 Jul 31 16:46 ntlm_auth -rwxr-xr-x. 1 root root 52760 Jul 31 16:45 oLschema2ldif -rwxr-xr-x. 1 root root 77696 Jul 31 16:46 pdbedit -rwxr-xr-x. 1 root root 23300 Jul 31 16:34 pidl -rwxr-xr-x. 1 root root 91888 Jul 31 16:46 profiles -rwxr-xr-x. 1 root root 43240 Jul 31 16:46 regdiff -rwxr-xr-x. 1 root root 47192 Jul 31 16:45 regpatch -rwxr-xr-x. 1 root root 74896 Jul 31 16:45 regshell -rwxr-xr-x. 1 root root 48648 Jul 31 16:45 regtree -rwxr-xr-x. 1 root root 2309320 Jul 31 16:46 rpcclient -rwxr-xr-x. 1 root root 215376 Jul 31 16:46 samba-regedit -rwxr-xr-x. 1 root root 1689 Jul 31 16:34 samba-tool -rwxr-xr-x. 1 root root 65448 Jul 31 16:46 sharesec -rwxr-xr-x. 1 root root 84320 Jul 31 16:45 smbcacls -rwxr-xr-x. 1 root root 205016 Jul 31 16:45 smbclient -rwxr-xr-x. 1 root root 97336 Jul 31 16:45 smbcontrol -rwxr-xr-x. 1 root root 51320 Jul 31 16:46 smbcquotas -rwxr-xr-x. 1 root root 45104 Jul 31 16:45 smbget -rwxr-xr-x. 1 root root 76072 Jul 31 16:46 smbpasswd -rwxr-xr-x. 1 root root 30008 Jul 31 16:46 smbspool -rwxr-xr-x. 1 root root 84024 Jul 31 16:47 smbstatus -rwxr-xr-x. 1 root root 4896 Jan 9 2017 smbtar -rwxr-xr-x. 1 root root 15578248 Jul 31 16:47 smbtorture -rwxr-xr-x. 1 root root 42912 Jul 31 16:46 smbtree -rwxr-xr-x. 1 root root 23920 Jul 31 16:45 tdbbackup -rwxr-xr-x. 1 root root 18056 Jul 31 16:45 tdbdump -rwxr-xr-x. 1 root root 17552 Jul 31 16:45 tdbrestore -rwxr-xr-x. 1 root root 38168 Jul 31 16:45 tdbtool -rwxr-xr-x. 1 root root 46488 Jul 31 16:46 testparm -rwxr-xr-x. 1 root root 107456 Jul 31 16:45 wbinfo
Pour pouvoir utiliser ces commandes, il convient d'ajouter le chemin à $PATH :
[root@centos7 bin]# PATH=/usr/local/samba/bin:$PATH [root@centos7 bin]# export PATH [root@centos7 bin]# echo $PATH /usr/local/samba/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Afin de rendre cette mofification permenante pour root, il faut éditer le fichier ~/.bash_profile :
[root@centos7 bin]# cd ~ [root@centos7 ~]# vi .bash_profile [root@centos7 ~]# cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=/usr/local/samba/bin:$PATH:$HOME/bin export PATH
Editez le fichier /etc/krb5.conf et mettre en commenataire la ligne includedir /etc/krb5.conf.d/ :
[root@centos7 ~]# vi /etc/krb5.conf [root@centos7 ~]# cat /etc/krb5.conf # Configuration snippets may be placed in this directory as well # includedir /etc/krb5.conf.d/ [logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] dns_lookup_realm = false ticket_lifetime = 24h renew_lifetime = 7d forwardable = true rdns = false # default_realm = EXAMPLE.COM default_ccache_name = KEYRING:persistent:%{uid} [realms] # EXAMPLE.COM = { # kdc = kerberos.example.com # admin_server = kerberos.example.com # } [domain_realm] # .example.com = EXAMPLE.COM # example.com = EXAMPLE.COM
Prcédez à une domain provision en utilisant la commande /usr/local/samba/bin/samba-tool :
Important : Une domain provision est la construction de votre domain de base et la construction du fichier smb.conf.
[root@centos7 ~]# /usr/local/samba/bin/samba-tool domain provision Realm [FENESTROS.LOC]: centosdom.fenestros.loc Domain [centosdom]: fenestros Server Role (dc, member, standalone) [dc]: DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: DNS forwarder IP address (write 'none' to disable forwarding) [8.8.8.8]: Administrator password: Retype password: Looking up IPv4 addresses Looking up IPv6 addresses No IPv6 address will be assigned Setting up share.ldb Setting up secrets.ldb Setting up the registry Setting up the privileges database Setting up idmap db Setting up SAM db Setting up sam.ldb partitions and settings Setting up sam.ldb rootDSE Pre-loading the Samba 4 and AD schema Adding DomainDN: DC=centosdom,DC=fenestros,DC=loc Adding configuration container Setting up sam.ldb schema Setting up sam.ldb configuration data Setting up display specifiers Modifying display specifiers Adding users container Modifying users container Adding computers container Modifying computers container Setting up sam.ldb data Setting up well known security principals Setting up sam.ldb users and groups Setting up self join Adding DNS accounts Creating CN=MicrosoftDNS,CN=System,DC=centosdom,DC=fenestros,DC=loc Creating DomainDnsZones and ForestDnsZones partitions Populating DomainDnsZones and ForestDnsZones partitions Setting up sam.ldb rootDSE marking as synchronized Fixing provision GUIDs A Kerberos configuration suitable for Samba AD has been generated at /usr/local/samba/private/krb5.conf Once the above files are installed, your Samba4 server will be ready to use Server Role: active directory domain controller Hostname: centos7 NetBIOS Domain: FENESTROS DNS Domain: centosdom.fenestros.loc DOMAIN SID: S-1-5-21-1643477231-2082225216-628174941
Important : Dans l'exemple ci-dessus le mot de passe P@$$w0rd est visible. Dans la réalité, il ne l'est pas. Il est important de noter que les règles concernant les mots de passe sont les suivantes : longueur minimale de 8 caractères dont au moins un majuscule et un chiffre.
Consultez maintenant le fichier /usr/local/samba/etc/smb.conf créé par le processus ci-dessus :
[root@centos7 ~]# cat /usr/local/samba/etc/smb.conf # Global parameters [global] netbios name = CENTOS7 realm = CENTOSDOM.FENESTROS.LOC workgroup = FENESTROS dns forwarder = 8.8.8.8 server role = active directory domain controller [netlogon] path = /usr/local/samba/var/locks/sysvol/centosdom.fenestros.loc/scripts read only = No [sysvol] path = /usr/local/samba/var/locks/sysvol read only = No
Important : Notez la présence des deux partages système créés par la commande /usr/local/samba/bin/samba-tool domain provision.
Démarrez maintenant samba4 :
[root@centos7 ~]# /usr/local/samba/sbin/samba
Visualiser les partages avec la commande smbclient :
[root@centos7 ~]# /usr/local/samba/bin/smbclient -L localhost -U% Domain=[FENESTROS] OS=[] Server=[] Sharename Type Comment --------- ---- ------- netlogon Disk sysvol Disk IPC$ IPC IPC Service (Samba 4.6.6) Domain=[FENESTROS] OS=[] Server=[] Server Comment --------- ------- Workgroup Master --------- -------
Testez le mecanisme d'authentification en utilisant de nouveau la commande smbclient :
[root@centos7 ~]# smbclient //localhost/netlogon -UAdministrator%'P@$$w0rd' -c 'ls' Domain=[FENESTROS] OS=[] Server=[] . D 0 Tue Aug 1 09:42:03 2017 .. D 0 Tue Aug 1 09:49:01 2017 10229760 blocks of size 1024. 5316272 blocks available
Consultez maintenant la liste des processus samba :
[root@centos7 ~]# ps aux | grep samba root 18755 0.1 1.7 577544 36516 ? Ss 09:51 0:00 /usr/local/samba/sbin/samba root 18761 0.0 1.1 577544 23252 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18762 0.2 1.4 582268 28836 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18763 0.0 1.1 577544 24464 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18764 0.0 1.1 577544 23132 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18765 1.0 1.2 577544 25840 ? S 09:51 0:01 /usr/local/samba/sbin/samba root 18766 0.0 1.1 577544 23572 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18767 0.0 1.2 577544 25472 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18768 0.1 1.2 577544 24624 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18769 0.0 1.1 577544 23240 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18770 0.0 1.1 577544 23236 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18771 0.0 1.6 577544 33184 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18772 0.0 1.1 577544 24224 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18773 0.0 1.2 577964 25400 ? S 09:51 0:00 /usr/local/samba/sbin/samba root 18774 0.1 1.9 629596 39864 ? Ss 09:51 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 18775 0.1 1.8 596408 38168 ? Ss 09:51 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 18784 0.0 1.1 623884 22940 ? S 09:51 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 18785 0.0 1.1 623908 23072 ? S 09:51 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 18786 0.0 1.2 602180 26244 ? S 09:51 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 18789 0.0 1.1 597356 24096 ? S 09:51 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 18795 0.0 1.2 602616 26092 ? S 09:51 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 18796 0.0 1.1 630104 23640 ? S 09:51 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 19600 0.0 0.0 114692 968 pts/0 R+ 09:53 0:00 grep --color=auto samba
Notez que selon systemctl, samba n'est pas démarré :
[root@centos7 ~]# systemctl status samba ● samba.service - Samba 4 Active Directory Loaded: loaded (/etc/systemd/system/samba.service; enabled; vendor preset: disabled) Active: inactive (dead)
Tuez tous les processus de samba :
[root@centos7 ~]# killall samba [root@centos7 ~]# ps aux | grep samba root 20478 0.0 0.0 114692 968 pts/0 R+ 09:56 0:00 grep --color=auto samba
Démarrez maintenant samba en utilisant systemctl et vérifiez son bon fonctionnement :
[root@centos7 ~]# systemctl start samba [root@centos7 ~]# ps aux | grep samba root 21578 5.3 1.7 577544 36512 ? Ss 09:59 0:00 /usr/local/samba/sbin/samba root 21586 0.0 1.1 577544 23248 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21587 0.3 1.3 581696 26864 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21588 0.3 1.1 577544 24460 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21589 0.0 1.1 577544 23128 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21590 19.0 1.2 577544 25560 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21591 0.0 1.1 577544 23560 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21592 0.0 1.2 579668 26432 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21593 0.0 1.1 577544 24444 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21594 0.0 1.1 577544 23236 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21595 0.0 1.1 577544 23232 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21596 0.0 1.1 577544 24124 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21597 0.0 1.1 577544 24100 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21598 0.0 1.2 580088 26336 ? S 09:59 0:00 /usr/local/samba/sbin/samba root 21600 10.3 2.6 699364 53812 ? S 09:59 0:00 python /usr/local/samba/sbin/samba_dnsupdate root 21602 5.3 1.9 629688 39664 ? Ss 09:59 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 21603 7.0 1.8 596260 37736 ? Ss 09:59 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 21616 0.0 1.1 624200 22944 ? S 09:59 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 21617 0.0 1.1 624200 22784 ? S 09:59 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 21619 0.0 1.2 604620 25948 ? S 09:59 0:00 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground root 21620 0.0 1.1 630212 23632 ? S 09:59 0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground root 21633 0.0 0.0 114692 968 pts/0 R+ 09:59 0:00 grep --color=auto samba [root@centos7 ~]# /usr/local/samba/bin/smbclient -L localhost -U% Domain=[FENESTROS] OS=[] Server=[] Sharename Type Comment --------- ---- ------- netlogon Disk sysvol Disk IPC$ IPC IPC Service (Samba 4.6.6) Domain=[FENESTROS] OS=[] Server=[] Server Comment --------- ------- Workgroup Master --------- -------
Notez que pour configurer firewalld celui-ci doit être démarré :
[root@centos7 ~]# firewall-cmd --add-port=53/tcp --permanent FirewallD is not running [root@centos7 ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) [root@centos7 ~]# systemctl enable firewalld Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service. Created symlink from /etc/systemd/system/basic.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service. [root@centos7 ~]# systemctl start firewalld [root@centos7 ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2017-08-01 10:05:18 CEST; 14s ago Docs: man:firewalld(1) Main PID: 23675 (firewalld) CGroup: /system.slice/firewalld.service └─23675 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Aug 01 10:05:18 centos7.fenestros.loc systemd[1]: Starting firewalld - dynamic firewall daemon... Aug 01 10:05:18 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon.
Créez maintenant les règles pour ouvrir les ports requis par samba :
[root@centos7 ~]# firewall-cmd --add-port=53/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=53/udp --permanent success [root@centos7 ~]# firewall-cmd --add-port=88/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=88/udp --permanent success [root@centos7 ~]# firewall-cmd --add-port=135/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=137-138/udp --permanent success [root@centos7 ~]# firewall-cmd --add-port=139/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=389/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=389/udp --permanent success [root@centos7 ~]# firewall-cmd --add-port=445/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=464/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=464/udp --permanent success [root@centos7 ~]# firewall-cmd --add-port=636/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=1024-5000/tcp --permanent success [root@centos7 ~]# firewall-cmd --add-port=3268-3269/tcp --permanent success
Dernièrement, rechargez la configuration afin de l'appliquer :
[root@centos7 ~]# firewall-cmd --reload success
Configurez maintenant votre fichier /etc/resolv.conf afin d'utiliser le serveur DNS de samba4 :
[root@centos7 ~]# nmcli connection mod ip_fixe ipv4.dns 10.0.2.6 [root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ip_fixe TYPE=Ethernet BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ip_fixe UUID=7c801069-d035-4f2f-8496-a96385b83bcd DEVICE=enp0s3 ONBOOT=yes DNS1=10.0.2.6 IPADDR=10.0.2.6 PREFIX=24 GATEWAY=10.0.2.2 IPV6_PEERDNS=yes IPV6_PEERROUTES=yes [root@centos7 ~]# systemctl restart NetworkManager.service [root@centos7 ~]# cat /etc/resolv.conf # Generated by NetworkManager search fenestros.loc nameserver 10.0.2.6
Re-démarrez samba et vérifiez que votre serveur DNS vous répond lors d'une requête :
[root@centos7 ~]# systemctl restart samba [root@centos7 ~]# systemctl status samba ● samba.service - Samba 4 Active Directory Loaded: loaded (/etc/systemd/system/samba.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2017-08-01 14:37:33 CEST; 9s ago Process: 15800 ExecStart=/usr/local/samba/sbin/samba (code=exited, status=0/SUCCESS) Main PID: 15805 (samba) CGroup: /system.slice/samba.service ├─15805 /usr/local/samba/sbin/samba ├─15810 /usr/local/samba/sbin/samba ├─15811 /usr/local/samba/sbin/samba ├─15812 /usr/local/samba/sbin/samba ├─15813 /usr/local/samba/sbin/samba ├─15814 /usr/local/samba/sbin/samba ├─15815 /usr/local/samba/sbin/samba ├─15816 /usr/local/samba/sbin/samba ├─15817 /usr/local/samba/sbin/samba ├─15818 /usr/local/samba/sbin/samba ├─15819 /usr/local/samba/sbin/samba ├─15820 /usr/local/samba/sbin/samba ├─15821 /usr/local/samba/sbin/samba ├─15822 /usr/local/samba/sbin/samba ├─15823 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground ├─15825 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─15835 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground ├─15836 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─15837 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─15847 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground ├─15848 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground └─15849 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground Aug 01 14:37:33 centos7.fenestros.loc samba[15814]: [2017/08/01 14:37:33.677779, 0] ../source4/lib/tls/tlscert.c:72(tls_cert_generate) Aug 01 14:37:33 centos7.fenestros.loc samba[15814]: Attempting to autogenerate TLS self-signed keys for https for hostname 'CENTOS7.centos...os.loc' Aug 01 14:37:34 centos7.fenestros.loc winbindd[15823]: [2017/08/01 14:37:34.166967, 0] ../source3/winbindd/winbindd_cache.c:3171(initialize..._cache) Aug 01 14:37:34 centos7.fenestros.loc winbindd[15823]: initialize_winbindd_cache: clearing cache and re-creating with version number 2 Aug 01 14:37:35 centos7.fenestros.loc winbindd[15823]: [2017/08/01 14:37:35.832250, 0] ../lib/util/become_daemon.c:124(daemon_ready) Aug 01 14:37:35 centos7.fenestros.loc winbindd[15823]: STATUS=daemon 'winbindd' finished starting up and ready to serve connections Aug 01 14:37:38 centos7.fenestros.loc samba[15814]: [2017/08/01 14:37:38.186065, 0] ../source4/lib/tls/tlscert.c:167(tls_cert_generate) Aug 01 14:37:38 centos7.fenestros.loc samba[15814]: TLS self-signed keys generated OK Aug 01 14:37:38 centos7.fenestros.loc smbd[15825]: [2017/08/01 14:37:38.382995, 0] ../lib/util/become_daemon.c:124(daemon_ready) Aug 01 14:37:38 centos7.fenestros.loc smbd[15825]: STATUS=daemon 'smbd' finished starting up and ready to serve connections Hint: Some lines were ellipsized, use -l to show in full. [root@centos7 ~]# nslookup www.linuxelearning.com Server: 10.0.2.6 Address: 10.0.2.6#53 Non-authoritative answer: Name: www.linuxelearning.com Address: 213.186.33.17
Testez maintenant le serveur DNS avec Samba. Vous devez obtenir un résultat similaire à celui-ci :
[root@centos7 ~]# host -t SRV _ldap._tcp.centosdom.fenestros.loc _ldap._tcp.centosdom.fenestros.loc has SRV record 0 100 389 centos7.centosdom.fenestros.loc. [root@centos7 ~]# [root@centos7 ~]# host -t SRV _kerberos._udp.centosdom.fenestros.loc _kerberos._udp.centosdom.fenestros.loc has SRV record 0 100 88 centos7.centosdom.fenestros.loc. [root@centos7 ~]# [root@centos7 ~]# host -t A centos7.centosdom.fenestros.loc centos7.centosdom.fenestros.loc has address 10.0.2.6
Important - Notez que la dernière commande doit retourner votre adresse IP.
Premièrement, identifiez votre realm :
[root@centos7 ~]# /usr/local/samba/bin/samba-tool testparm --suppress-prompt | grep realm realm = CENTOSDOM.FENESTROS.LOC
Lors de l'installation de Samba, un fichier de configuration type de Kerberos a été sauvegardé dans /usr/local/samba/share/setup/ :
[root@centos7 ~]# cat /usr/local/samba/share/setup/krb5.conf [libdefaults] default_realm = ${REALM} dns_lookup_realm = false dns_lookup_kdc = true
Editez ce fichier en fonction de votre realm :
[root@centos7 ~]# vi /usr/local/samba/share/setup/krb5.conf [root@centos7 ~]# cat /usr/local/samba/share/setup/krb5.conf [libdefaults] default_realm = CENTOSDOM.FENESTROS.LOC dns_lookup_realm = false dns_lookup_kdc = true
Important - Notez que le nom du realm est en MAJUSCULES.
Sauvegardez votre fichier /etc/krb5.conf existant puis remplacez-le avec le fichier type que vous venez de modifier :
[root@centos7 ~]# cp /etc/krb5.conf /root [root@centos7 ~]# cp /usr/local/samba/share/setup/krb5.conf /etc cp: overwrite ‘/etc/krb5.conf’? y
Testez ensuite la connexion au domaine afin d'obtenir un ticket ( ou jeton ) kerberos :
[root@centos7 ~]# kinit administrator@CENTOSDOM.FENESTROS.LOC Password for administrator@CENTOSDOM.FENESTROS.LOC: P@$$w0rd Warning: Your password will expire in 41 days on Tue 12 Sep 2017 14:31:14 CEST
Important - La commande kinit sert à obtenir et mettre en cache un ticket ( ou jeton ) kerberos. Pour plus d'informations concernant la commande kinit, consultez la page du manuel : man kinit. Notez que le mot de passe P@$$w0rd ne sera pas visible.
Visualisez ensuite le ticket :
[root@centos7 ~]# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: administrator@CENTOSDOM.FENESTROS.LOC Valid starting Expires Service principal 01/08/17 14:44:09 02/08/17 00:44:09 krbtgt/CENTOSDOM.FENESTROS.LOC@CENTOSDOM.FENESTROS.LOC renew until 02/08/17 14:44:01
Important - La commande klist sert à afficher les tickets ( ou jetons ) kerberos dans le cache. Pour plus d'informations concernant la commande klist, consultez la page du manuel : man klist.
Important - Arretez votre machine virtuelle et y ajouter un disque supplémentaire de type vmdk, de taille 8Go et nommé share. Démarrez votre machine virtuelle CentOS_7.
Creéz une seule partition sur le nouveau disque :
[root@centos7 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xa423c6ab. Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xa423c6ab Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-16777215, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): Using default value 16777215 Partition 1 of type Linux and of size 8 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Creéz maintenant un système de fichiers ext4 sur /dev/sdb1 :
[root@centos7 ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 524288 inodes, 2096896 blocks 104844 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2147483648 64 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Modifiez votre fichier /etc/fstab afin de monter automatiquement /dev/sdb1 avec des options user_xattr et acl :
[root@centos7 ~]# ls -l /dev/disk/by-uuid/ | grep sdb1 lrwxrwxrwx. 1 root root 10 Aug 1 14:58 891354b2-7b30-4393-9869-cfd095900200 -> ../../sdb1 [root@centos7 ~]# vi /etc/fstab [root@centos7 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Apr 30 11:27:02 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / xfs defaults 0 0 UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot xfs defaults 0 0 UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults 0 0 UUID=891354b2-7b30-4393-9869-cfd095900200 /share ext4 user_xattr,acl 0 0
Montez la partition sur le point de montage /share :
[root@centos7 ~]# mkdir /share [root@centos7 ~]# mount -a [root@centos7 ~]# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=1010008k,nr_inodes=252502,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/sda2 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota) selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel) debugfs on /sys/kernel/debug type debugfs (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel) nfsd on /proc/fs/nfsd type nfsd (rw,relatime) tmpfs on /tmp type tmpfs (rw,seclabel) /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime) fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=204868k,mode=700,uid=1000,gid=1000) gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000) tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=204868k,mode=700) /dev/sdb1 on /share type ext4 (rw,relatime,seclabel,data=ordered)
Modifiez /usr/local/samba/etc/smb.conf :
[root@centos7 ~]# vi /usr/local/samba/etc/smb.conf [root@centos7 ~]# cat /usr/local/samba/etc/smb.conf # Global parameters [global] netbios name = CENTOS7 realm = CENTOSDOM.FENESTROS.LOC workgroup = FENESTROS dns forwarder = 8.8.8.8 server role = active directory domain controller [netlogon] path = /usr/local/samba/var/locks/sysvol/centosdom.fenestros.loc/scripts read only = No [sysvol] path = /usr/local/samba/var/locks/sysvol read only = No [share] path = /share read only = No
Redémarrez samba4 :
[root@centos7 ~]# systemctl restart samba [root@centos7 ~]# systemctl status samba ● samba.service - Samba 4 Active Directory Loaded: loaded (/etc/systemd/system/samba.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2017-08-02 09:10:42 CEST; 8s ago Process: 2570 ExecStart=/usr/local/samba/sbin/samba (code=exited, status=0/SUCCESS) Main PID: 2571 (samba) CGroup: /system.slice/samba.service ├─2571 /usr/local/samba/sbin/samba ├─2576 /usr/local/samba/sbin/samba ├─2577 /usr/local/samba/sbin/samba ├─2578 /usr/local/samba/sbin/samba ├─2579 /usr/local/samba/sbin/samba ├─2580 /usr/local/samba/sbin/samba ├─2581 /usr/local/samba/sbin/samba ├─2582 /usr/local/samba/sbin/samba ├─2583 /usr/local/samba/sbin/samba ├─2584 /usr/local/samba/sbin/samba ├─2585 /usr/local/samba/sbin/samba ├─2586 /usr/local/samba/sbin/samba ├─2587 /usr/local/samba/sbin/samba ├─2588 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground ├─2589 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─2592 /usr/local/samba/sbin/samba ├─2593 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─2594 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground ├─2595 /usr/local/samba/sbin/winbindd -D --option=server role check:inhibit=yes --foreground └─2597 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground Aug 02 09:10:42 centos7.fenestros.loc samba[2571]: [2017/08/02 09:10:42.518909, 0] ../source4/smbd/server.c:487(binary_smbd_main) Aug 02 09:10:42 centos7.fenestros.loc samba[2571]: samba: using 'standard' process model Aug 02 09:10:42 centos7.fenestros.loc samba[2571]: [2017/08/02 09:10:42.569470, 0] ../lib/util/become_daemon.c:124(daemon_ready) Aug 02 09:10:42 centos7.fenestros.loc samba[2571]: STATUS=daemon 'samba' finished starting up and ready to serve connections Aug 02 09:10:42 centos7.fenestros.loc winbindd[2588]: [2017/08/02 09:10:42.826363, 0] ../source3/winbindd/winbindd_cache.c:3171(initialize_..._cache) Aug 02 09:10:42 centos7.fenestros.loc winbindd[2588]: initialize_winbindd_cache: clearing cache and re-creating with version number 2 Aug 02 09:10:43 centos7.fenestros.loc winbindd[2588]: [2017/08/02 09:10:43.568911, 0] ../lib/util/become_daemon.c:124(daemon_ready) Aug 02 09:10:43 centos7.fenestros.loc winbindd[2588]: STATUS=daemon 'winbindd' finished starting up and ready to serve connections Aug 02 09:10:43 centos7.fenestros.loc smbd[2589]: [2017/08/02 09:10:43.735365, 0] ../lib/util/become_daemon.c:124(daemon_ready) Aug 02 09:10:43 centos7.fenestros.loc smbd[2589]: STATUS=daemon 'smbd' finished starting up and ready to serve connections Hint: Some lines were ellipsized, use -l to show in full.
Pour gérer les permissions des partages à partir de Windows, vous avez besoin du privilège SeDiskOperatorPrivilege :
[root@centos7 ~]# net rpc rights grant 'BUILTIN\Administrators' SeDiskOperatorPrivilege -Uadministrator Enter administrator's password:P@$$w0rd Successfully granted rights.
Dernièrement vérifiez que le privilège est disponible :
[root@centos7 ~]# net rpc rights list accounts -Uadministrator Enter administrator's password:P@$$w0rd BUILTIN\Print Operators SeLoadDriverPrivilege SeShutdownPrivilege SeInteractiveLogonRight BUILTIN\Account Operators SeInteractiveLogonRight BUILTIN\Backup Operators SeBackupPrivilege SeRestorePrivilege SeShutdownPrivilege SeInteractiveLogonRight BUILTIN\Administrators SeSecurityPrivilege SeBackupPrivilege SeRestorePrivilege SeSystemtimePrivilege SeShutdownPrivilege SeRemoteShutdownPrivilege SeTakeOwnershipPrivilege SeDebugPrivilege SeSystemEnvironmentPrivilege SeSystemProfilePrivilege SeProfileSingleProcessPrivilege SeIncreaseBasePriorityPrivilege SeLoadDriverPrivilege SeCreatePagefilePrivilege SeIncreaseQuotaPrivilege SeChangeNotifyPrivilege SeUndockPrivilege SeManageVolumePrivilege SeImpersonatePrivilege SeCreateGlobalPrivilege SeEnableDelegationPrivilege SeInteractiveLogonRight SeNetworkLogonRight SeRemoteInteractiveLogonRight SeDiskOperatorPrivilege BUILTIN\Server Operators SeBackupPrivilege SeSystemtimePrivilege SeRemoteShutdownPrivilege SeRestorePrivilege SeShutdownPrivilege SeInteractiveLogonRight BUILTIN\Pre-Windows 2000 Compatible Access SeRemoteInteractiveLogonRight SeChangeNotifyPrivilege
Commencez par importer la machine virtuelle de Windows™ 10 puis configurez le réseau en tant que Réseau NAT > NatNetwork.
Configurez la machine virtuelle en IP fixe :
Vérifiez l'accès à Internet et la communication avec le serveur Samba :
Mettez la machine virtuelle dans le domiane FENESTROS :
IMPORTANT - NE RE-DEMARREZ PAS LA MACHINE VIRTUELLE.
Afin de gérer le domaine FENESTROS de samba, nous avons besoin des outils Microsoft Remote Server Tools (RSAT). Téléchargez ces outils à partir de l'adresse https://wiki.samba.org/index.php/Installing_RSAT.
Installez ensuite les outils :
Redémarrez la machine virtuelle Windows™ 10 et ouvrez une session sur le domaine FENESTROS avec administrator/P@$$w0rd.
Exécutez ensuite dsa.msc :
Cliquez droit sur centosdom.fentros.loc puis sur Nouveau > Utilisateur :
Créez l'utilisateur linuxuser avec le mot de passe Wind0ws :
<html>
Copyright © 2004-2017 I2TCH LIMITED.<br><br>
</html>