Mit Samba steht seit 1992 eine Implementation des SMB-Protokolls auch auf UNIX-Systemen (Linux etwas später) zur Verfügung. Ab Samba 3.6 (ab Ubuntu 14.04 LTS) wurden dann auch die Protokolle SMBv2 und SMBv3 schrittweise als Optionen nach Samba übernommen. Seit September 2017 ist nun auch in Samba SMBv3 Standard, und seit Samba 4.11 (ab Ubuntu 20.04 LTS) wird, wie auch in Windows 10, das Protokoll SMBv1 in der Grundeinstellung nicht mehr unterstützt.
Mit Hilfe von NSS und PAM kann Samba sogar einen Active Directory Domänencontroller ersetzen.
apt install samba
edit /etc/samba/smb.conf
[Global] workgroup = WORKGROUP security = user map to guest = Bad User name resolve order = bcast host include = /etc/samba/shares.conf [Public Files] path = /share/public_files force user = smbuser force group = smbgroup create mask = 0664 force create mode = 0664 directory mask = 0775 force directory mode = 0775 public = yes writeable = yes [Protected Files] path = /share/protected_files force user = smbuser force group = smbgroup create mask = 0664 force create mode = 0664 directory mask = 0775 force directory mode = 0775 public = yes writeable = no
mkdir -p /share/public_files mkdir -p /share/protected_files groupadd --system smbgroup useradd --system smbuser --no-create-home --group smbgroup -s /bin/false chown -R smbuser:smbgroup /share chmod -R g+w /share // add a new user useradd newuser // add as smbuser smbpasswd -a newuser // delete as smbuser smbpasswd -x newuser systemctl start smbd systemctl status smbd
Set static ip, edit
/etc/network/interfaces
<pre> iface eth0 iface eth0 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 127.0.0.1 192.168.0.1 8.8.8.8 dns-search example.com </code>
Edit hostname in
/etc/hostname
und
/etc/hosts
.
/etc/hostname
dc.example.com
/etc/hosts
127.0.0.1 localhost 192.168.0.2 dc.example.com dc ...
Install packages
apt install -y samba krb5-user krb5-config winbind smbclient // opt additional libpam-winbind libnss-winbind
Stop services
systemctl stop samba-ad-dc smbd nmbd winbind systemctl disable samba-ad-dc smbd nmbd winbind
Remove example config
rm /etc/samba/smb.conf
Domain provision
example
samba-tool domain provision --interactive --use-rfc2307 --use-ntvfs mv /etc/krb5.conf /etc/krb5.conf.bak ln -s /var/lib/samba/private/krb5.conf /etc/ systemctl start samba-ad-dc systemctl enable samba-ad-dc
Edit
/etc/resolv.conf
.
search example.com nameserver 127.0.0.1 nameserver 192.168.0.1 nameserver 8.8.8.8
Test dc.
samba-tool domain level show ping example.com ping dc.example.com ping dc host -t SRV _ldap._tcp.example.com host -t SRV _kerberos._udp.example.com host -t A example.com host -t A dc.example.com
Test kerberos
kinit administrator@example.com klist
samba-tool user create user1 samba-tool user enable user1 samba-tool group add group1 samba-tool group addmembers group1 user1,user2,.. samba-tool group removemembers group1 user1,user2,.. samba-tool group delete group1
// to create a unix group in samba samba-tool group add groupname --nis-domain=samdom --gid-number=<next available GID>