1.简介
Samba是一套使用SMB(Server Message Block)协议的应用程序, 通过支持这个协议, Samba允许Linux服务器与Windows系统之间进行通信,使跨平台的互访成为可能。
2.系统环境
系统版本:centos6.7
服务器IP: 10.220.5.166/24
3.关闭安全服务
[root@ken ~]# service iptables stop [root@ken ~]# setenforce 0
4. 安装samba
[root@ken ~]# yum install samba -y
5.配置samba
[root@ken ~]# vim /etc/samba/smb.conf ... # Backend to store user information in. New installations should 98 # use either tdbsam or ldapsam. smbpasswd is available for backwar ds 99 # compatibility. tdbsam requires no further configuration. 100 101 security = share #101行处修改安全级别为share 102 passdb backend = tdbsam 103 104 105 # ----------------------- Domain Members Options ----------------- ------- 106 # 107 # Security must be set to domain or ads 108 # 109 # Use the realm option only with security = ads 110 # Specifies the Active Directory realm the host is part of ... .... 246 #============================ Share Definitions ================== ============ 247 [ken] #247行处添加如下代码,等号前后需要有空格 248 comment = ken 249 path = /ken #定义共享路径 250 writable = yes 251 public = yes
6.创建共享目录
[root@ken ~]# mkdir /ken
7.修改共享目录权限
[root@ken ~]# chmod -R 777 /ken
8.重启samba服务
[root@ken ~]# service smb restart
Shutting down SMB services: [FAILED]
Starting SMB services: [ OK ]
9.window访问
按回车键
10.写入数据测试
测试完成。
补充
由于centos7中安全级别已经不再支持share,因此安全级别必须为user.
1.系统环境
centos7.5
2.错误信息
[root@ken ~]# testparm /etc/samba/smb.conf Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) WARNING: Ignoring invalid value 'share' for parameter 'security' Error loading services.
3.故障排除
... # passdb backend = the backend used to store user information in. New # installations should use either tdbsam or ldapsam. No additional configuration # is required for tdbsam. The "smbpasswd" utility is available for backwards # compatibility. # security = user #安全级别修改为user passdb backend = tdbsam # ----------------------- Domain Members Options ------------------------ # # security = must be set to domain or ads. # # passdb backend = the backend used to store user information in. New # installations should use either tdbsam or ldapsam. No additional configuration # is required for tdbsam. The "smbpasswd" utility is available for backwards # compatibility. ...
4.创建用户
[root@ken ~]# useradd -r -s /sbin/nologin ken
5.创建管理共享资源的账户
[root@ken ~]# pdbedit -a -u ken new password: retype new password: Unix username: ken NT username: Account Flags: [U ] User SID: S-1-5-21-3572927365-2803509514-2985628482-1000 Primary Group SID: S-1-5-21-3572927365-2803509514-2985628482-513 Full Name: Home Directory: \localhostken ...
6.重启服务
[root@ken ~]# systemctl restart smb
7.浏览器测试
输入账户和密码
测试成功!