grep -v “^#” /etc/samba/smb.conf.example | grep -v “^;” | grep -v “^$”
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
-----------------以上是默认的samba配置文件------------
----------------------配置匿名共享---------------------
systemctl stop firewalld
setenforce 0
vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
vi /etc/fstab
/dev/cdrom /mnt iso9660 defaults 0 0
mount -a
---------------以上上配置yum仓库---------------
yum install -y samba
mkdir /opt/aa
vi /etc/samba/smb.conf
security = share
[database]
comment = this is test file
path = /opt/aa
public = yes
testparm
systemctl start smb
systemctl enable smb
测试:
windows:运行里面输入\192.168.80.110
——————————配置用户密码验证——————————
vi /etc/samba/smb.conf
security = user
[database]
comment = this is test file
path = /opt/aa
public = yes
writable = yes
testparm
useradd -s /sbin/nologin jack
–注意:SMABA用户是系统用户,但是密码不是系统密码,是SAMBA服务器的密码-
pdbedit -a -u jack
pdbedit -L
systemctl restart smb
测试:
windows:运行里面输入\192.168.80.110
net use /d * //清除微软系统的共享访问缓存,让用户可以切换其它账号登录
————————————————————————————
----------------以下是配置对共享目录的权限-------------
vi /etc/samba/smb.conf
security = share
[database]
comment = this is test file
path = /opt/aa
public = yes
read only = yes
writable = yes
valid users = jack,tom //可以通过 @test 加组名
write list = jack
directory mask = 0700
create mask = 0640
hosts deny = 192.168.80.6
hosts allow = 192.168.80.0 173.11.0.0
0可以省略,多个网段可以以空格做间隔符
PS: write list = … > read only = yes > writable = yes
“;”是注释
只有某某有写权限,只需 write list = 用户或组名(基本组)
//注意一下系统目录本身的权限对用户是否有读写执行
————————————————————————————
----------------------配置共享帐号映射(别名)---------
vi /etc/samba/smbusers
hunter = sunboy player
vi /etc/samba/smb.conf
[global]
username map = /etc/samba/smbusers
systemctl restart smb
------------------windows共享目录,linux去连接-------
yum install cifs-utils -y
yum install samba-client -y
smbclient -L 192.168.80.6
smbclient -L 192.168.80.6 -U jack
mount.cifs //192.168.80.6/ISO-all /media/ 匿名共享直接挂载 要有mount.cifs命令
yum provides mount.cifs
mount -o username=jack //192.168.80.6/ISO-all /media/
-----------------以上临时的-------------
vi /etc/fstab
//192.168.80.10/共享文件 /opt/bb cifs username=administrator,password=123 0 0
-----------------------永久挂载-----------------
vim auth.smb
username=jack
password=123
domain=MYGROUP
vi /etc/fstab
//192.168.80.110/test /opt/dd cifs credentials=/root/auth.smb 0 0
注意:cifs:是samba的共享文件的格式