Centos7 -samba服務配置
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建立的訪問用戶密碼
便可訪問共享的目錄