Différences entre versions de « Samba »

De Cliss XXI
Sauter à la navigation Sauter à la recherche
imported>SylvainBeucler
imported>SylvainBeucler
Ligne 337 : Ligne 337 :
 
<pre>
 
<pre>
 
wget http://freefr.dl.sourceforge.net/sourceforge/gqclient/gq-1.2.3.tar.gz
 
wget http://freefr.dl.sourceforge.net/sourceforge/gqclient/gq-1.2.3.tar.gz
 +
tar xzf gq-1.2.3.tar.gz
 +
cd gq-1.2.3
 
# Required
 
# Required
 
apt-get install libgtk2.0-dev libglib2.0-dev libxml2-dev libgnome-keyring-dev libglade2-dev libxml-parser-perl libldap2-dev
 
apt-get install libgtk2.0-dev libglib2.0-dev libxml2-dev libgnome-keyring-dev libglade2-dev libxml-parser-perl libldap2-dev
Ligne 345 : Ligne 347 :
 
sudo make install
 
sudo make install
 
</pre>
 
</pre>
 
  
 
== Voir aussi ==
 
== Voir aussi ==

Version du 17 mai 2009 à 20:58

Une configuration minimale

[global]
        workgroup = ANGRES
        passdb backend = tdbsam

[homes]
        comment = Répertoire personnel de %u
        read only = no

[monpartage]
        comment = Description longue de mon partage
        read only = no
        path = /srv/samba/monpartage

Noter qu'un partage partage est read only par défaut, d'où la nécessité de désactiver cette option.

Le passbd backend implicite est smbpasswd qui ne permet pas de stocker tous les champs utilisateurs (durée de validité, etc.), on utilise donc tdbsam d'office pour ne pas avoir de surprises par la suite.

Créer un dossier partagé

cd /srv/samba/groups
mkdir nom_du_partage
chmod o= nom_du_partage
chmod g=rwxs nom_du_partage
chgrp nom_du_partage nom_du_partage

Puis modifier le fichier de configuration de Samba /etc/samba/smb.conf:

[nom_du_partage]
 comment = Répertoire pour ...
 force group = nom_du_partage
 path = /srv/samba/groups/nom_du_partage
 valid users = @nom_du_partage
 read only = no
 create mask = 0660
 directory mask = 0770

On teste la configuration avec:

testparm

On relance le serveur de fichiers:

/etc/init.d/samba restart

Noter l'astuce pour forcer le bon groupe dans les répertoires partagés:

[qualite]
...
 force group = +qualite
...
[prod]
...
 force group = +prod

Conserver la compatibilité avec MS Woe9X et WoeMe

La nouvelle version dans Debian Lenny (3.2.5) désactive implicitement les vieux clients, ce qui a également pour conséquence d'EFFACER tous les mots de passe dans l'ancien format. Il faut donc - AVANT de mettre à jour - rajouter ceci dans la configuration:

lanman auth = yes
client plaintext auth = yes
client lanman auth = yes

Pour plus d'information, cf. /usr/share/doc/samba/NEWS.Debian.gz:

samba (3.0.27a-2) unstable; urgency=low

  * Weak authentication methods are disabled by default

    Beginning with this version, plaintext authentication is disabled for
    clients and lanman authentication is disabled for both clients and
    servers.  Lanman authentication is not needed for Windows
    NT/2000/XP/Vista, Mac OS X or Samba, but if you still have Windows
    95/98/ME clients (or servers) you may need to set lanman auth (or client
    lanman auth) to yes in your smb.conf.

    The "lanman auth = no" setting will also cause lanman password hashes to
    be deleted from smbpasswd and prevent new ones from being written, so
    that these can't be subjected to brute-force password attacks.  This
    means that re-enabling lanman auth after it has been disabled is more
    difficult; it is therefore advisable that you re-enable the option as
    soon as possible if you think you will need to support Win9x clients.

    Client support for plaintext passwords is not needed for recent Windows
    servers, and in fact this behavior change makes the Samba client behave
    in a manner consistent with all Windows clients later than Windows 98.
    However, if you need to connect to a Samba server that does not have
    encrypted password support enabled, or to another server that does not
    support NTLM authentication, you will need to set
    "client plaintext auth = yes" and "client lanman auth = yes" in smb.conf.

 -- Steve Langasek <vorlon@debian.org>  Sat, 24 Nov 2007 00:23:37 -0800

Configuration LDAP

OpenLDAP

apt-get install slapd
dpkg-reconfigure slapd
apt-get install samba-doc
zcat /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz > /etc/ldap/schema/samba3.schema

Modifier /etc/ldap/slapd.conf et ajouter:

include /etc/ldap/schema/samba3.schema
invoke-rc.d slapd restart

Système UNIX

cat <<EOF | debconf-set-selections
libnss-ldap     shared/ldapns/ldap-server       string  ldap://127.0.0.1/
libnss-ldap     shared/ldapns/base-dn   string  dc=chezmoi,dc=fr
libnss-ldap     libnss-ldap/rootbinddn  string  cn=admin,dc=chezmoi,dc=fr
libnss-ldap     libnss-ldap/rootbindpw  password  admin
EOF

apt-get install libnss-ldap
cat <<EOF >> /etc/libnss-ldap.conf
nss_base_passwd ou=people,dc=chezmoi,dc=fr
nss_base_shadow ou=people,dc=chezmoi,dc=fr
nss_base_group  ou=groups,dc=chezmoi,dc=fr
EOF

sed -i -e 's/^\(passwd:.*$\)/\1 ldap/' \
       -e 's/^\(group:.*$\)/\1 ldap/'  \
       -e 's/^\(shadow:.*$\)/\1 ldap/' \
    /etc/nsswitch.conf

SMB-LDAP-Tools:

apt-get install smbldap-tools
zcat /usr/share/doc/smbldap-tools/examples/smbldap.conf.gz \
   > /etc/smbldap-tools/smbldap.conf
chmod 644 /etc/smbldap-tools/smbldap.conf
  • comment SSID="..."
  • sambaDomain="CHEZMOI"
  • suffix="dc=chezmoi,dc=fr"
  • groupsdn="ou=groups,${suffix}"
  • computersdn="ou=people,${suffix}" # same than users, otherwise WXP won't join the domain %(
  • usersdn="ou=people,${suffix}"
  • idmapdn="ou=people,${suffix}"
  • sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}"
  • hash_encrypt="CRYPT"
  • defaultMaxPasswordAge="-1" # (http://www.planetmy.com/blog/ldap-samba-pdc/)
  1. sambaSID mantadory: `net getlocalsid` . "$uidNumber" > uid=admin/sambaSID
cp /usr/share/doc/smbldap-tools/examples/smbldap_bind.conf \
   /etc/smbldap-tools/smbldap_bind.conf
chmod 600 /etc/smbldap-tools/smbldap_bind.conf
  • masterDN="cn=admin,dc=chezmoi,dc=fr"
  • masterPw="secret"
smbldap-populate
cat <<EOF | ldapmodify -c -x -D 'cn=admin,dc=chezmoi,dc=fr' -W
dn: sambaDomainName=CHEZMOI,dc=chezmoi,dc=fr
changetype: modify
replace: uidNumber
uidNumber: 3000
-
replace: sambaNextRid
sambaNextRid: 3000
EOF
# Not necessary:
#gidNumber: 3000
  • Set uidNumber=3000 - only machines will use this script, and this will avoid conflicts with webmin.
  • Not sure about the 'sambaNextRid', it seems it's defined when the computer joins the domain (not in 'smbldap-useradd -w')

Samba

workgroup = CHEZMOI

# I use LDAP
passdb backend = ldapsam
#passdb backend = ldapsam:ldap://ldap-server.chezmoi.fr
ldap suffix = dc=chezmoi,dc=fr
ldap admin dn = cn=admin,dc=chezmoi,dc=fr
ldap user suffix = ou=people
ldap group suffix = ou=groups
#ldap machine suffix = ou=computers
ldap machine suffix = ou=people
ldap idmap suffix = ou=people
ldap passwd sync = yes
# Jonction de machines au domaine:
add machine script = /usr/sbin/smbldap-useradd -w "%u"

# Pour les dossiers personnels
root preexec = /root/smb_mkhomedir.sh %U
mkdir -m 755 /srv/samba/
mkdir -m 755 /srv/samba/netlogon

Définir le mot de passe LDAP:

smbpasswd -W

Créer automatiquement les dossiers personnels:

#!/bin/bash
echo `date -R` $0 $* >> /var/log/smb_mkhomedir.log

user="$1"

homedir=`getent passwd $user | cut -d: -f 6`
# Validate homedir starts with "/home/"
if ! echo $homedir | grep ^/home/ >/dev/null; then
    exit 1
fi
# Don't do anything if the path already exists
if [ -e homedir ]; then
    exit 0
fi

mkdir -p -m 755 $homedir
chown $user: $homedir

Changer le nom de domaine:

  • modifier avec gq (ou autre interface d'édition)
  • mettre à jour dans /etc/smbldap-tools/
  • mettre à jour dans /etc/samba/smb.conf


Configuration Webmin

(testé sous Webmin 1.400)

# Debian-specific Webmin patch
ln -s libnss-ldap.secret ldap.secret
  • LDAP Users and Groups
    • Enabled Samba account by default? => Yes
    • Show fields for given name and surname? [otherwise "Failed to add user to LDAP database : object class 'inetOrgPerson' requires attribute 'sn'"] => Yes
    • Object class to add for given name? [otherwise "objectclass: value #4 invalid per syntax" because webmin will add an empty class] => inetOrgPerson
    • Domain SID for Samba3 [necessary?] => S-1-5-21-XXXXXXXXXX-XXXXXXXXX-XXXXXXXXXX
    • LDAP object class for Samba groups [necessary?] => sambaGroupMapping (Samba 3 new schema)
  • Users and Groups
    • Default primary group for new users => "Domain Users"
    • Default shell for new users => /bin/false
  • LDAP Client
    • Root LDAP client password file => /etc/libnss-ldap.secret

Configuration PDC

PDC = Primary Domain Controller = CPD = Contrôleur Principal de Domaine = terminologie microsoft pour dire serveur d'identification

Suivre la configuration LDAP, puis:

# I'm a PDC
domain logons = yes
# I'm a master browser
domain master = yes
local master = yes

## <configuration plus agressive>
# Au cas où:
preferred master = yes
os level = 65
# Si pas de Win98, supprimer le port 139 (les déconnexions de WXP sont logguées)
#smb ports = 445
# Ne pas activer s'il y a un autre wins sur le réseau:
wins support = yes
dns proxy = no
socket options = TCP_NODELAY
## </configuration plus agressive>

# Homedir
logon drive = Z:
logon script = %U.bat
## Disable roaming profiles:
#logon path =
#logon home =
# UnDisable roaming profiles:
# (default: logon path = \\%N\%U\profile)
logon path = \\%h\%U\profile


[netlogon]
path = /srv/samba/netlogon
read only = yes
browsable = no
comment = Scripts de connexion et Stratégies Systèmes
force directory mode = 755
force create mode = 644
# Debian tips:
share modes = no
guest ok = yes

Dépannage PDC

À tester: désactiver RequireSignOrSeal:

3 valeurs:

; http://lists.samba.org/archive/samba/2005-July/108896.html
; force Windows XP Professional clients to accept Samba as a PDC
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters]
"requiresignorseal"=dword:00000000
"signsecurechannel"=dword:00000000 
; Do not check for user ownership of Roaming Profile Folders
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
"CompatibleRUPSecurity"=dword:00000001


qg

Pas dispo sous Lenny (mainteneur pas actif depuis 2 ans), on peut le compiler à la main:

wget http://freefr.dl.sourceforge.net/sourceforge/gqclient/gq-1.2.3.tar.gz
tar xzf gq-1.2.3.tar.gz
cd gq-1.2.3
# Required
apt-get install libgtk2.0-dev libglib2.0-dev libxml2-dev libgnome-keyring-dev libglade2-dev libxml-parser-perl libldap2-dev
# Optional
apt-get install libkrb5-dev libsasl2-dev libssl-dev
./configure
make
sudo make install

Voir aussi

Samba et accès concurrents

Liens