Samba: interoperabilità libera con il mondo Microsoft Relatore: Andrea Micheli Linux Day 2004 Fabio Calefato ForTIC / C2 / Moduli 7,9 1
Cosa e' Samba Samba è un insieme di programmi che permettono di integrare un PC Linux in ambienti di rete Microsoft Windows o LanManager compatibili e consentendo di: Condividere file, directory e stampanti. Effettuare l'autenticazione dei client che si connettono ad un Dominio Windows. Assumere il browsing completo di una rete. Fornire o assistere alla risoluzione dei nomi WINS. Fabio Calefato ForTIC / C2 / Moduli 7,9 2
Samba caratteristiche Samba utilizza il protocollo SMB (Server message block) definito per reti Windows e a sua volta basato sull'interfaccia di rete NetBIOS (Network basic input output system). SMB è stato progettato originariamente per reti molto piccole. Per permettere la connessione a reti più estese ed eterogenee, Microsoft ha sviluppato il sistema CIFS (Common internet file system) ancora basato su NetBIOS. Samba può essere a tutti gli effetti considerato una versione libera e gratuita di CIFS; con esso, una macchina GNU/Linux, può accedere alle risorse condivise di Windows ma anche mettere a disposizione proprie risorse a clienti MS Windows o GNU/Linux. Fabio Calefato ForTIC / C2 / Moduli 7,9 3
Samba Demoni Alla base del funzionamento si sono tre demoni (servizi): smbd: Gestisce le condivisioni di file e stampanti, nonché l autenticazione. nmbd: Supporta NetBIOS Name Service and WINS e gestisce il browsing delle risorse condivise. winbind: Gestisce autenticazione di client/server Unix su Domini Microsoft Fabio Calefato ForTIC / C2 / Moduli 7,9 4
Samba Le possibilita' Configurazione File server Printer server Primary domain controller Backup domain controller Active Directory domain controller Windows 95/98/Me authentication Windows NT/2000/XP authentication Primary WINS server Secondary WINS server Si Si Si Si No Si Si Si No Fabio Calefato ForTIC / C2 / Moduli 7,9 5
Samba Scaricare il software I Pacchetti binari di Samba sono inclusi in molte delle distribuzioni Linux. Comunque il sito web principale per il software di Samba è http://www.samba.org Fabio Calefato ForTIC / C2 / Moduli 7,9 6
Fabio Calefato ForTIC / C2 / Moduli 7,9 7
Samba La configurazione di Samba è salvata nel file smb.conf, normalmente risiede in etc/samba/smb.conf o in usr/local/samba/lib/smb.conf Se non si vuole editare direttamente il file esiste incluso con i binari di Samba un tools di configurazione via interfaccia Web: SWAT Fabio Calefato ForTIC / C2 / Moduli 7,9 8
Fabio Calefato ForTIC / C2 / Moduli 7,9 9
Avviare i demoni Eseguire /etc/init.d/smb start Avvio automatico al boot: creare i links allo script smb in /etc/rc.d/rcx.d # ln s /etc/rc.d/init.d/smb /etc/rc.d/rc3.d/s35smb # ln s /etc/rc.d/init.d/smb /etc/rc.d/rc5.d/s35smb Verifica: # smbclient U% L localhost Fabio Calefato ForTIC / C2 / Moduli 7,9 10
smbpasswd Aggiungere password degli utenti nel database di samba. # smbpasswd a corsoc2 Fabio Calefato ForTIC / C2 / Moduli 7,9 11
Configurazione client: Windows 2000 Fabio Calefato ForTIC / C2 / Moduli 7,9 12
Configurazione client: TCP Fabio Calefato ForTIC / C2 / Moduli 7,9 13
WINS server Fabio Calefato ForTIC / C2 / Moduli 7,9 14
Definizione del Workgroup Fabio Calefato ForTIC / C2 / Moduli 7,9 15
Samba come PDC [global] workgroup = SAMBADOMAIN netbios name = GURU server string = Samba Server # option to set this samba server as PDC domain master = yes local master = yes preferred master = yes os level = 65 domain logons = yes Fabio Calefato ForTIC / C2 / Moduli 7,9 16
Samba come PDC ; logon path tells Samba where to put Windows NT/2000/XP roaming profiles logon path = \\%L\profiles\%u\%m logon script = logon.bat logon drive = H: time server = yes ; use the names of all users in the Windows NT/2000/XP ; Administrators group who log on to the domain domain admin group = root fabio add user script = /usr/sbin/useradd d /dev/null g 100 s /bin/false M %u Fabio Calefato ForTIC / C2 / Moduli 7,9 17
Samba come PDC [netlogon] path = /usr/local/samba/lib/netlogon writable = no browsable = no [profiles] ; you might wish to use a different directory for your Windows NT/2000/XP roaming profiles path = /home/samba ntprof browsable = no writable = yes create mask = 0600 directory mask = 0700 [homes] read only = no browsable = no guest ok = no map archive = yes Fabio Calefato ForTIC / C2 / Moduli 7,9 18
Samba come PDC # mkdir /usr/local/samba/lib/netlogon # chmod 775 /usr/local/samba/lib/netlogon # mkdir /home/samba ntprof # chmod 777 /home/samba ntprof Fabio Calefato ForTIC / C2 / Moduli 7,9 19
Samba come PDC Creare lo script di logon con vi (:se ff=dos) in /usr/local/samba/lib/netlogon net time \\guru /set /yes Riavviare samba server # /etc/rc.d/init.d/smb restart # smbpasswd a root Fabio Calefato ForTIC / C2 / Moduli 7,9 20
Entrare nel dominio Fabio Calefato ForTIC / C2 / Moduli 7,9 21
Samba come PDC Fabio Calefato ForTIC / C2 / Moduli 7,9 22
Montare cartelle condivise di Windows con samba Fabio Calefato ForTIC / C2 / Moduli 7,9 23
Montare cartelle condivise di Windows con samba Sono equivalenti: smbmount //hal80686/mp3 /mnt/samba/ mount t smbfs //hal80686/mp3 /mnt/samba/ Fabio Calefato ForTIC / C2 / Moduli 7,9 24
Smb.conf # /etc/samba/smb.conf # Copyright (c) 2004 # [global] # only needed for wins replication (wrepl) # wins partners = 192.168.0.1 172.16.1.2 # default: # smb ports = 139 445 # to disable netbios also disable nmbd! # disable netbios = yes # utmp = yes workgroup = TUX NET Fabio Calefato ForTIC / C2 / Moduli 7,9 25
Smb.conf # choose your passdb backend # options: smbpasswd, smbpasswd_nua, tdbsam, tdbsam_nua, ldapsam, ldapsam_nua, plugin # default: passdb backend = smbpasswd # passdb backend = smbpasswd:/etc/samba/smbpasswd ldapsam:ldap://localhost tdbsam:/etc/samba/passdb.tdb # passdb backend = ldapsam:ldap://localhost # passdb backend = ldapsam:ldaps://localhost # passdb backend = smbpasswd # passdb backend = plugin:/path/to/plugin.so:pluging args # needed for one the nua backends # non unix account range = 5000 50000 # algorithmic rid base = 100000 Fabio Calefato ForTIC / C2 / Moduli 7,9 26
Smb.conf # sample for the new pdb_msql backend # passdb backend = [other plugins] plugin:/location/to/pdb_mysql.so:identifier [other plugins] # identifier:mysql host host name, defaults to 'localhost' # identifier:mysql password # identifier:mysql user defaults to 'samba' # identifier:mysql database defaults to 'samba' # identifier:mysql port defaults to 3306 # identifier:table Name of the table containing users # choose your auth method: # options: guest, rhosts, hostsequiv # sam (passdb direct hash access) # unix (PAM, crypt() etc) # local (the combination of the above, based on encryption) # smbserver (old security=server) # ntdomain (old security=domain) #winbind (use winbind to cache DC connections) #auth methods = winbind Fabio Calefato ForTIC / C2 / Moduli 7,9 27
Smb.conf # time server = yes interfaces = 127.0.0.1 eth0 bind interfaces only = true # this enables MS Distributed File System. # host msdfs = yes # printing... printing = cups printcap name = cups load printers = yes # guest handling # map to guest = nobody # restrict anonymous = 0 (see man smb.conf) # is this a wins server? # wins server = 192.168.1.1 # wins support = no Fabio Calefato ForTIC / C2 / Moduli 7,9 28
Smb.conf # is this a BDC? # local master = yes # domain master = no # domain logons = yes # security = user # is this a PDC? # local master = yes # domain master = yes # domain logons = yes # security = user # is this a domain member? # local master = no # domain master = no # domain logons = no # security = ads # security = domain Fabio Calefato ForTIC / C2 / Moduli 7,9 29
Smb.conf # generic logon script? (passdb) # logon script = test.bat # where to store user profiles? (passdb) # logon path = \\%N\profiles\%u # where is a user's home directory and where should it # be mounted? (passdb) # logon drive = H: # logon home = \\%N\%u Fabio Calefato ForTIC / C2 / Moduli 7,9 30
Smb.conf # winbind # don't forget to prepare your /etc/nsswitch.conf and your /etc/pam.d files # this will only work if you have joined your NT domain # winbind separator = + # winbind use default domain = yes # winbind cache time = 600 # template shell = /bin/bash # template homedir = /home/%u # idmap uid = 10000 20000 # idmap gid = 10000 20000 # idmap backend = ldap:ldap://localhost # winbind enum groups = yes # winbind enum users = yes # security = domain # security = ads # password server = win2ksrv Fabio Calefato ForTIC / C2 / Moduli 7,9 31
Smb.conf # ldapsam # add rootpw to secrets.tdb with "smbpasswd w secret" # ldap admin dn = cn=manager,o=myorg # ldap suffix = ou=samba3,o=myorg # ldap machine suffix = ou=computers # ldap group suffix = ou=groups # ldap idmap suffix = ou=idmap # ldap user suffix = ou=users # ldap tls/ssl (yes, no (default), start_tls) # ldap ssl = yes # ldap passwd sync = yes # Active Directory integration # realm = MY.REALM.DE # security = ads Fabio Calefato ForTIC / C2 / Moduli 7,9 32
FINE Fabio Calefato ForTIC / C2 / Moduli 7,9 33