简介
Samba是一种可以在Linux和UNIX系统中实现SMB/CIFS协议的软件,它允许用户通过网络共享文件和打印机,本文将详细介绍如何配置Linux Samba服务器,包括安装、配置文件、用户管理等方面的内容。
安装Samba
1、更新系统软件包列表:
sudo apt-get update
2、安装Samba及其相关工具:
sudo apt-get install samba samba-common-bin
3、安装完成后,启动Samba服务:
sudo systemctl start smbd nmbd nmbdadm
4、设置开机自启动:
sudo systemctl enable smbd nmbd nmbdadm
配置文件
1、Samba的主配置文件位于/etc/samba/smb.conf
,可以使用文本编辑器进行编辑:
sudo nano /etc/samba/smb.conf
2、在配置文件中,可以设置以下参数:
workgroup:工作组名称,与Windows系统的相同;
server string:服务器描述;
netbios name:网络基本输入输出系统(NetBIOS)名称;
security modes:安全模式,如user、share、domain;
encrypt passwords:是否加密密码;
map to guest account:是否映射到guest账户;
max log size:日志文件最大大小;
logging levels:日志记录级别;
socket options:套接字选项;
idmap config file:ID映射配置文件;
[share]共享名:共享目录的配置信息,如路径、权限等。
以一个简单的示例为例:
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = centos security = user encrypt passwords = yes map to guest account = bad user max log size = 100M logging levels = debug,notice,info,warnings,error socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536 SO_KEEPALIVE=YES NO_ROOT_SCANNING=1 Tcp_Keepalive_Time=1200 TCP_USER_TIMEOUT=300 TCP_KEEPIDLE=600 Idle_Time=3000 TCP_RECV_TIMEOUT=300 TCP_REUSEADDR=1 TCP_SYNCNT=1 TCP_LINGER2=15 UDP_CONNRESET=1 PROTOCOLS=TCP UDP IPV4_FAILURE_FATAL=no IPV6_FAILURE_FATAL=no REUSEPORT=yes UNIX_PATH_MODE=0777 Samba Master Browser Style=master browser unix group=wheel home dir=%h web disk_size=1024M max log size=10485760 write list=@admin vfat umask=0002 local time sync waittime=3600 logon time=24 hours passwd chat=off isroaming=off force chroot=off template homedir=%h force user=centos no create mask=0777 winbind use default domain=\\SERVERNAME audit failed attempts failauth retries minrate rate limit auth users read only = no list = @users read list = @readusers write list = @writeusers force group = admins force user = centos force mech = plain public ok username map = none hide full path = no valid users = @validusers force public = yes writable acl = nodev unbind defeauls acl add speciality=masked acl add speciality=system acl add speciality=hidden acl add speciality:speciality deny rwx execute disable setuid setgid sticky bit mode mask=0x0f00 mask2=0x1f00 mask3=0x2700 mask4=0x3f00 extended rights mask=0x1ffffffff mask2=0x1fffffe mask3=0x1ffffffe mask4=0x1fffffffe extended attributes mask=none relabel mask=none label mask=none allow root = cifs deny root = cifs hosts allow = * deny = * hosts deny = ALL hosts allow = %s local master = no local master = %s workgroup = WORKGROUP shared folder = %s comment = This is a Samba share on %s network drive read only = no browseable = yes guest ok = yes writable = yes read only = no force user = nobody force group = nobody public = yes anon quota maxbytes = unlimited anon quota days = unlimited anon quota users = nobody anon quota roots = nobody anon quota soft limits = unlimited anon quota hard limits = unlimited writable acl add speciality:speciality deny rwx execute disable setuid setgid sticky bit mode mask=0x0f00 mask2=0x1f00 mask3=0x2700 mask4=0x3f00 extended rights mask=0x1ffffffff mask2=0x1fffffe mask3=0x1ffffffe mask4=0x1fffffffe extended attributes mask=none relabel mask=none label mask=none allow root = cifs deny root = cifs hosts allow = * deny = * hosts deny = ALL hosts allow = %s local master = no local master = %s workgroup = WORKGROUP shared folder = %s comment = This is a Samba share on %s network drive read only = no browseable = yes guest ok = yes writable = yes read only = no force user = nobody force group = nobody public = yes anon quota maxbytes = unlimited anon quota days = unlimited anon quota users = nobody anon quota roots = nobody anon quota soft limits = unlimited anon quota hard limits = unlimited writable acl add speciality:speciality deny rwx execute disable setuid setgid sticky bit mode mask=0x0f00 mask2=0x1f00 mask3=0x2700 mask4=0x3f00 extended rights mask=0x1ffffffff mask2=0x1fffffe mask3=0x1ffffffe mask4=0x1fffffffe extended attributes mask=none relabel mask=none label mask=none allow root = cifs deny root = cifs hosts allow = * deny = * hosts deny = ALL hosts allow = %s local master = no local master = %s workgroup = WORKGROUP shared folder = %s comment = This is a Samba share on %s network drive read only = no browseable = yes guest ok
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/210464.html