tech:serveur_samba_smb_cifs
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:serveur_samba_smb_cifs [2026/02/04 13:41] – Jean-Baptiste | tech:serveur_samba_smb_cifs [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Serveur Samba SMB CIFS | ||
| + | |||
| + | Voir aussi | ||
| + | * [[Samba-client SMB CIFS]] | ||
| + | * https:// | ||
| + | * ksmbd: un nouveau serveur SMB intégré au noyau (mais problématique de sécurité) | ||
| + | |||
| + | |||
| + | |||
| + | ## Notes | ||
| + | |||
| + | RHEL6 ne supporte pas le protocole SMB2 et + | ||
| + | |||
| + | ## Configuration | ||
| + | |||
| + | ~~~ | ||
| + | rlimit_max (1024) below minimum Windows limit (16384) | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | root | ||
| + | ~~~ | ||
| + | |||
| + | Défaut est `max open files = 16385` | ||
| + | |||
| + | Voir https:// | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | workgroup = WORKGROUP | ||
| + | server string = Samba | ||
| + | netbios name = SAMBA | ||
| + | client ipc min protocol = SMB3 | ||
| + | client min protocol = SMB3 | ||
| + | server min protocol = SMB2 | ||
| + | disable netbios = Yes | ||
| + | disable spoolss = Yes | ||
| + | domain master = No | ||
| + | load printers = No | ||
| + | local master = No | ||
| + | log file = / | ||
| + | | ||
| + | # Size in KB | ||
| + | max log size = 200000 | ||
| + | | ||
| + | name resolve order = host | ||
| + | printcap name = /dev/null | ||
| + | security = USER | ||
| + | smb ports = 445 | ||
| + | idmap config * : backend = tdb | ||
| + | passdb backend = tdbsam | ||
| + | cups options = raw | ||
| + | printing = bsd | ||
| + | #log level = 3 | ||
| + | #restrict anonymous = 2 | ||
| + | #nt pipe support = no | ||
| + | #interfaces = eth* lo | ||
| + | #bind interfaces only = yes | ||
| + | #fstype = Samba | ||
| + | host msdfs = no | ||
| + | server services = -s3fs, -rpc, -nbt, -wrepl, -ldap, -cldap, -kdc, -drepl, -winbindd, -ntp_signd, -kcc, -dnsupdate, -dns | ||
| + | |||
| + | [public] | ||
| + | comment = Public | ||
| + | read only = Yes | ||
| + | path = / | ||
| + | | ||
| + | [shared] | ||
| + | #guest ok = Yes | ||
| + | #browseable = No | ||
| + | comment = Shared | ||
| + | path = /mnt/shared | ||
| + | read only = No | ||
| + | #force user = jean | ||
| + | valid users = jean | ||
| + | write list = jean | ||
| + | | ||
| + | #[IPC$] | ||
| + | # hosts allow = 192.168.115.0/ | ||
| + | # hosts deny = 0.0.0.0/0 | ||
| + | ~~~ | ||
| + | |||
| + | Nul besoin de redémarrer le service, les modifications sont automatiquement prises en compte. | ||
| + | Pour vérifier | ||
| + | |||
| + | ~~~bash | ||
| + | testparm | ||
| + | ~~~ | ||
| + | |||
| + | Pour tester la connexion | ||
| + | ~~~bash | ||
| + | smbclient -N -L 127.0.0.1 | ||
| + | smbclient -N // | ||
| + | smbclient -U user%password // | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | Si besion modifier `/ | ||
| + | |||
| + | ~~~bash | ||
| + | #iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT | ||
| + | iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | Exemple : | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [partage] | ||
| + | | ||
| + | path = /var/www | ||
| + | force user = web | ||
| + | # | ||
| + | | ||
| + | | ||
| + | ~~~ | ||
| + | |||
| + | Valider la configuration | ||
| + | |||
| + | ~~~bash | ||
| + | testparm | ||
| + | ~~~ | ||
| + | |||
| + | Reload de la conf sans redémarrer | ||
| + | ~~~bash | ||
| + | smbcontrol all reload-config | ||
| + | ~~~ | ||
| + | |||
| + | Redémarrer le service | ||
| + | |||
| + | ~~~bash | ||
| + | systemctl restart smb | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### Faire un include d'un fichier de config. | ||
| + | |||
| + | C'est une fausse bonne idée car pas de reload automatique | ||
| + | |||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | path = /dev/null | ||
| + | |||
| + | [includes] | ||
| + | available = No | ||
| + | include = / | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [shared] | ||
| + | comment = Shared | ||
| + | path = /mnt/shared | ||
| + | read only = No | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Authentification / comptes | ||
| + | |||
| + | Comment c'est configuré | ||
| + | ~~~bash | ||
| + | testparm -sv /dev/null | grep auth | ||
| + | |||
| + | testparm -s ' | ||
| + | ~~~ | ||
| + | |||
| + | Autoriser un utilisateur / définition du MDP | ||
| + | ~~~bash | ||
| + | #pdbedit -a utilisateur | ||
| + | smbpasswd -a utilisateur | ||
| + | ~~~ | ||
| + | |||
| + | Les utilisateurs à ajouter doivent exister au préalable dans / | ||
| + | |||
| + | Cette option (et les suivantes) n'est disponible que lorsque smbpasswd est exécuté en tant que root | ||
| + | |||
| + | |||
| + | Supprimer un compte (retour arrière à précédent) | ||
| + | ~~~bash | ||
| + | smbpasswd -x supervision | ||
| + | ~~~ | ||
| + | |||
| + | Désactiver un compte | ||
| + | ~~~bash | ||
| + | smbpasswd -d supervision | ||
| + | ~~~ | ||
| + | |||
| + | Liste tous les comptes | ||
| + | ~~~bash | ||
| + | pdbedit -L | ||
| + | ~~~ | ||
| + | |||
| + | Vérif l’existence de l' | ||
| + | ~~~bash | ||
| + | pdbedit -u pirate | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Dans un script shell | ||
| + | |||
| + | ~~~ | ||
| + | $ echo -n " | ||
| + | UEBzc3cwcmQ= | ||
| + | ~~~ | ||
| + | |||
| + | Duplication de l' | ||
| + | ~~~bash | ||
| + | # tee /dev/stdout | ||
| + | |||
| + | echo " | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Désactiver l' | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | load printers = no | ||
| + | printing = bsd | ||
| + | printcap name = /dev/null | ||
| + | disable spoolss = yes | ||
| + | ~~~ | ||
| + | |||
| + | Source : http:// | ||
| + | |||
| + | |||
| + | ## Debug | ||
| + | |||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | log level = 3 | ||
| + | ~~~ | ||
| + | |||
| + | Pas besoin de redémarrer le service, le reload est auto | ||
| + | |||
| + | ## Notes | ||
| + | |||
| + | ~~~bash | ||
| + | smbstatus | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ## Pb | ||
| + | |||
| + | ### Receiving SMB: Server stopped responding - Call returned zero bytes (EOF) opening remote | ||
| + | |||
| + | ~~~ | ||
| + | smb: \> get plop | ||
| + | Receiving SMB: Server stopped responding | ||
| + | Call returned zero bytes (EOF) opening remote file \plop | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | #### Solution | ||
| + | |||
| + | Le pb venait du fait que la partition `/var` était pleine. | ||
| + | |||
| + | |||
| + | ### Pb de connection depuis windows err NT_STATUS_WRONG_PASSWORD | ||
| + | |||
| + | |||
| + | Voir https:// | ||
| + | |||
| + | |||
| + | #### Solution 1 (insecure) | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | ntlm auth = yes | ||
| + | #client ntlmv2 auth = yes | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ----------------------- | ||
| + | |||
| + | Exemple de conf | ||
| + | |||
| + | Install sous RedHat / CentOS | ||
| + | |||
| + | ~~~bash | ||
| + | cp -p / | ||
| + | egrep -v ' | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [global] | ||
| + | | ||
| + | dns proxy = no | ||
| + | log file = / | ||
| + | max log size = 1000 | ||
| + | | ||
| + | panic action = / | ||
| + | | ||
| + | | ||
| + | obey pam restrictions = yes | ||
| + | unix password sync = yes | ||
| + | | ||
| + | | ||
| + | pam password change = yes | ||
| + | map to guest = bad user | ||
| + | | ||
| + | |||
| + | [tmp] | ||
| + | path = /tmp | ||
| + | | ||
| + | | ||
| + | read only = no | ||
| + | | ||
| + | | ||
| + | guest ok = yes | ||
| + | |||
| + | [partage] | ||
| + | | ||
| + | path = /data/ | ||
| + | force user = utilisateur1 | ||
| + | # | ||
| + | valid users = @groupe1, jean | ||
| + | write list = @groupe1, jean | ||
| + | | ||
| + | | ||
| + | read only = no | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | Pour conteneurs | ||
| + | |||
| + | ~~~bash | ||
| + | / | ||
| + | ~~~ | ||
| + | |||
