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
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
# use either tdbsam or ldapsam. smbpasswd is available for backwar ds
# compatibility. tdbsam requires no further configuration. security = share #101行处修改安全级别为share
passdb backend = tdbsam # ----------------------- Domain Members Options ----------------- -------
#
# Security must be set to domain or ads
#
# Use the realm option only with security = ads
# Specifies the Active Directory realm the host is part of
...
....
#============================ Share Definitions ================== ============
[ken] #247行处添加如下代码,等号前后需要有空格
comment = ken
path = /ken #定义共享路径
writable = yes
public = yes
6.创建共享目录
[root@ken ~]# mkdir /ken
7.修改共享目录权限
[root@ken ~]# chmod -R /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 () to minimum Windows limit ()
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-------
Primary Group SID: S-------
Full Name:
Home Directory: \\localhost\ken
...
6.重启服务
[root@ken ~]# systemctl restart smb
7.浏览器测试
输入账户和密码
测试成功!