# apt install samba # mkdir -p /disk2/samba && chown games /disk2/samba
# cat /etc/samba/smb.conf
[global] security = user map to guest = Bad User [ast_records] force user = asterisk path = /var/spool/asterisk/monitor/ guest ok = Yes [distrs] force user = games path = /var/distrs guest ok = Yes
# mkdir /var/distrs # cd /var/distrs # wget http://val.bmstu.ru/unix/Mail/Thunderbird%20Setup%2017.0.msi
!!! Липовое окно аутентификации возникает в случае совпадения имени пользователя Windows с пользователем зарегистрированным в /etc/passwd
# cat /etc/samba/smb.conf
[global] unix charset = UTF-8 dos charset = cp866 workgroup = CORPX security = user # hosts allow = 192.168.100+X. 192.168.200+X. map to guest = Bad User [pub_share] path = /disk2/samba guest ok = yes read only = no force user = games # browseable = no
# testparm
Добавляем пользователей user1 и user2 на server (Управление учетными записями в Linux)
!!! smbd должен быть запущен!!!
server# smbpasswd -a user1 New SMB password: wpassword1 server# (echo wpassword2; echo wpassword2) | smbpasswd -a user2 # pdbedit -w -L # smbpasswd -x user1 # cat /etc/samba/smb.conf
[global] unix charset = UTF-8 dos charset = cp866 workgroup = CORPX security = user [homes] read only = no valid users = %S ; sometimes solves the problem permission deny ;;;; users = %U ; force user=%U [corp_share] path = /disk2/samba valid users = user1 user2 games # valid users = @group1 games force user = games read only = No
!!! В FreeBSD samba должна быть скомпилирована с поддержкой ADS !!!
server# kadmin -l
kadmin> add -r cifs/gate.corpX.un kadmin> add -r cifs/gate.CORPX.UN kadmin> ext -k gatecifs.keytab cifs/gate.corpX.un kadmin> ext -k gatecifs.keytab cifs/gate.CORPX.UN
server# kadmin.local
kadmin.local: addprinc -randkey cifs/gate.corpX.un kadmin.local: addprinc -e rc4-hmac:normal -randkey cifs/gate.CORPX.UN kadmin.local: ktadd -k gatecifs.keytab cifs/gate.corpX.un kadmin.local: ktadd -k gatecifs.keytab cifs/gate.CORPX.UN
server# scp gatecifs.keytab gate:
Login: gatecifs Password: Pa$$w0rd
Пароль не меняется и не устаревает
Устанавливаем Microsoft Windows Support Tools
C:\>ktpass -princ cifs/gate.corpX.un@CORPX.UN -mapuser gatecifs -pass 'Pa$$w0rd' -out gatecifs.keytab
C:\>pscp gatecifs.keytab gate:
gate# ktutil copy /root/gatecifs.keytab /etc/krb5.keytab gate# ktutil list
root@gate:~# ktutil
ktutil: rkt /root/gatecifs.keytab ktutil: list ktutil: wkt /etc/krb5.keytab ktutil: quit root@gate:~# klist -k /etc/krb5.keytab
gate# cat /etc/samba/smb.conf
[global] ... security = user realm = CORPX.UN kerberos method = system keytab ...
Авторизация в режиме ADS (Сервис WINBIND)
Примечание: достаточно зарегистрировать SAMBA сервер в домене, принципал cifs не нужен
Авторизация в режиме DOMAIN (Сервис WINBIND)
gate# cat /etc/samba/smb.conf
[global] ... [homes] ; may be need make homedir read only = no valid users = %S [corp_share] path = /disk2/samba ;with winbind ; valid users = CORPX\user1 CORPX\Administrator CORPX\root ; valid users = @CORPX\group1 ; valid users = "@CORPX\domain users" ;without winbind, group1 must be master group ; valid users = @group1 games ;without winbind ; valid users = user1 user2 games read only = no force user = games
# cat /etc/pam.d/samba
... @include common-session-noninteractive session optional pam_mkhomedir.so
gate# cat /etc/samba/smb.conf
[global] ... obey pam restrictions = yes
# cat /etc/samba/smb.conf
[global] ... max log size = 0 log file = /var/log/samba/log.%I log level = 10 debug pid = yes debug uid = yes debug class = yes debug hires timestamp = yes ...
# smbstatus
# cat /etc/samba/smb.conf
... vfs objects = full_audit full_audit:prefix = %U|%u|%I|%m|%S full_audit:success = connect, open, mkdir, rmdir, unlink, write, rename full_audit:failure = none full_audit:priority = NOTICE ...
# service smbd restart # tail -f /var/log/syslog
# cat smb.conf
[global] ... server string = MS File Server ...