1.安装
$ sudo yum install samba samba-client -y
2.设置开机自动启动
$ sudo systemctl enable smb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
3.启动samba服务
$ sudo systemctl start smb.service
4.查看samba服务的状态
$ sudo systemctl status smb.service
smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2016-09-29 19:59:07 CST; 52s ago
Main PID: 4816 (smbd)
...
5.配置配置文件
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak //备份配置文件
$ sudo >smb.conf //清空配置文件
$ sudo vim smb.conf
- 输入如下内容
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ==============================
[django_project]
path = /home/caideyang/Documents/project //分享的目录
browsable =yes
writable = yes
guest ok = yes
read only = no
public = no
vaild users = caideyang //客户端登陆用户
6.创建samba用户
$ sudo smbpasswd -a caideyang
7.创建需分享的目录路径
$ mkdir -p /home/caideyang/Documents/project
8.重启samba服务
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service
9.添加防火墙规则
$ sudo firewall-cmd --permanent --zone=public --add-service=samba
$ sudo firewall-cmd --reload
10.客户端访问
-
windows下键入win+R组合键,输入 "\<samba_server_ip>"
- 输入samba创建的访问用户密码
- 即可访问共享的目录