1. 安裝 Samba Server
# yum install samba
2. 修改設定檔 /etc/samba/smb.conf
# cat /etc/samba/smb.conf | grep -E -v ‘^#|^;’
[global]
workgroup = HOME
server string = Samba Server Version %v
# log files split per-machine:
log file = /var/log/samba/log.%m
# maximum size of 50KB per log file, then rotate:
max log size = 50
security = user
passdb backend = tdbsam
[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
veto files=/.*
[@more@]3. 測試設定檔
# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[homes]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
workgroup = HOME
server string = Samba Server Version %v
security = USER
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
[homes]
comment = Home Directories
valid users = %S
read only = No
veto files = /.*
browseable = No
4. 建立使用者 Samba 密碼
# /usr/bin/pdbedit -a t850008
new password:
retype new password:
Unix username: t850008
NT username:
Account Flags: [U ]
User SID: S-1-5-21-1562595748-815096285-1647261660-1000
Primary Group SID: S-1-5-21-1562595748-815096285-1647261660-513
Full Name:
Home Directory: \localhostt850008
HomeDir Drive:
Logon Script:
Profile Path: \localhostt850008profile
Domain: LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: Wed, 06 Feb 2036 23:06:39 CST
Kickoff time: Wed, 06 Feb 2036 23:06:39 CST
Password last set: Wed, 29 Jun 2016 09:06:19 CST
Password can change: Wed, 29 Jun 2016 09:06:19 CST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
5. SELinux 在 Samba Server 上設定
# setsebool -P samba_enable_home_dirs on
如果有另外分享的目錄
# semanage fcontext -a -t samba_share_t ‘/sharedpath(/.*)?’
# restorecon -RFvv /sharedpath
6. 設定開機時啟動 Samba Server
# systemctl enable smb
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
# systemctl enable nmb
Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
7. 啟動 Samba Server
# systemctl start smb
# systemctl start nmb
8. 檢查是否有正常啟動
# netstat -an | grep -E ‘:137|:138|:139|:445’
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN
tcp6 0 0 :::139 :::* LISTEN
tcp6 0 0 :::445 :::* LISTEN
udp 0 0 0.0.0.0:137 0.0.0.0:*
udp 0 0 0.0.0.0:138 0.0.0.0:*