CentOS下Samba配置实例

发布时间:2020-04-05 发布网站:大佬教程
大佬教程收集整理的这篇文章主要介绍了CentOS下Samba配置实例大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
环境介绍:

CentOS下Samba配置实例

1、安装前准备

1) selinux (或直接disable)
[root@smb ~] setsebool -P samba_enable_home_dirs on
[root@smb ~]setsebool -P samba_export_all_rw on

2) iptables

[root@smb ~] skip...................

3)系统目录及用户与组创建 (留意大小写)
[root@smb ~] mkdir -pv /smb/{Sales,Develop,Public}
[root@smb ~] groupadd ops
[root@smb ~] useradd -G ops -s /sbin/nologin zhang3
[root@smb ~] groupadd develop
[root@smb ~] useradd -G develop -s /sbin/nologin li4
[root@smb ~] groupadd Boss
[root@smb ~] useradd -G Boss -s /sbin/nologin wang5
[root@smb ~] groupadd sales
[root@smb ~] useradd -G sales -s /sbin/nologin zhao6

[root@smb ~] chmod 1777 /smb/{Sales,Develop}
[root@smb ~] chmod 1777 /smb/Public

[root@smb ~] chgrp sales /smb/Sales
[root@smb ~] chgrp develop /smb/Develop
[root@smb ~] chgrp ops /smb/Public

2、安装

[root@smb ~] yum-y install samba samba-client# client可以不装

3、配置主文件

[root@smb ~] vi /etc/samba/smb.conf

#============================= Global Setting =============================
workgroup = WORKGROUP
server string = Samba Server Version %v
netbios name = SHARE FILE SERVER
guest account = nobody
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936

encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
username map = /etc/samba/smbusers

os level = 40
local master = yes
preferred master = yes


; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
; hosts allow = 127. 192.168.12. 192.168.13.

max log size = 50
security = user
passdb backend = tdbsam

cups options = raw
disable spoolss = yes
load printers = no
printing = bsd
printcap name = /dev/null


#============================= Global Setting =============================
;[homes]
; comment = Home Directories
; browseable = no
; writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S


[Sales]
path = /smb/Sales
comment = Sales Depart Share Folder
browseable = yes
guest ok = no
writeable = no
valid users = @sales,@Boss
write list = @ sales

[Develop]
path = /smb/Develop
comment = Develop Depart Share Folder
browseable = yes
guest ok = no
writeable = no
valid users = @develop
write list = @develop

[Public]
path = /smb/Public
comment = Public Share Folder
browseable = yes
guest ok = no
writeable = no
valid users = @develop,@Boss,@sales
admin users = zhang3
write list = @ops
invalid users = root




4、添置用户及设置密码
1)通过smbpasswd
[root@smb ~] smbpasswd -a zhang3
2) 通过pdbedit
[root@smb ~] pdbedit -a li4

pdbedit –a username:新建Samba账户。
pdbedit –x username:删除Samba账户。
pdbedit –L:列出Samba用户列表,读取passdb.tdb数据库文件。
pdbedit –Lv:列出Samba用户列表的详细信息。
pdbedit –c “[D]” –u username:暂停该Samba用户的账号。
pdbedit –c “[]” –uusername:恢复该Samba用户的账号。

客户端登陆状态
[root@smb ~]smbstatus

Linux 客户端连接(回车直接查看)
[root@smb ~]smbclient -L //192.168.109.237/Public

[root@smb ~]smbclient -U zhang3 //192.168.109.237/Public
smbclient -U zhang3 //192.168.109.237/Public
Enter zhang3's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-169.el6_5]
smb: \>help

挂载
[root@smb ~]mount -t cifs //192.168.109.237/Pulic /mnt/smb/Public -o username=zhang3,password=<password>

大佬总结

以上是大佬教程为你收集整理的CentOS下Samba配置实例全部内容,希望文章能够帮你解决CentOS下Samba配置实例所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ群:277859234,请注明来意。