SAMBA服務(wù)器

SAMBA可以實(shí)現(xiàn)在局域網(wǎng)內(nèi)Linux/UNIX和Windows的文件共享和打印機(jī)共享
本文環(huán)境是CentOS Linux release 7.1.1503 (Core)
cat /etc/redhat-release

0x01 安裝SAMBA
# 查看
yum list all samba*
# 安裝
yum -y install samba.x86_64
0x02 配置SAMBA
# 配置文件路徑
/etc/samba/
# 配置文件說明,samba的配置文件分段
grep -i 'Options -' /etc/samba/smb.conf
#======================= Global Settings =====================================
[global]
# ----------------------- Network-Related Options -------------------------
        workgroup = MYGROUP
        server string = Samba Server Version %v
;       netbios name = MYSERVER
;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
;       hosts allow = 127. 192.168.12. 192.168.13.
;       max protocol = SMB2
# --------------------------- Logging Options -----------------------------
        # 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
# ----------------------- Standalone Server Options ------------------------
        security = user
        passdb backend = tdbsam
# ----------------------- Domain Members Options ------------------------
;       security = domain
;       passdb backend = tdbsam
;       realm = MY_REALM

;       password server = <NT-Server-Name>
# ----------------------- Domain Controller Options ------------------------
# ----------------------- Browser Control Options ----------------------------
;       local master = no
;       os level = 33
;       preferred master = yes
# --------------------------- Printing Options -----------------------------
        load printers = yes
        cups options = raw
;       printcap name = /etc/printcap
        # obtain a list of printers automatically on UNIX System V systems:
;       printcap name = lpstat
;       printing = cups
# --------------------------- File System Options ---------------------------
#============================ Share Definitions ==============================
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S
[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes
        
[shared name]
    comments = 
    path = 
    browseable = 
    public = // guest ok = 
    read only = 
    writable = // read only與writable如果同時(shí)間出現(xiàn),哪個(gè)嚴(yán)格遵從哪個(gè)
    write list = user1, user2, @group1
    valid users = // 白名單
    invalid users = // 黑名單
    
# 測試配置文件是否OK
testparm
# 啟動(dòng)服務(wù)
systemctl start smb
# 查看端口 samba使用端口139/tcp,445/tcp
netstat -tunlp
# 將系統(tǒng)用戶加入Samba賬戶(密碼單獨(dú)的)
smbpasswd -a ysai
0x03 配置SELinux
chcon -t samba_share_t /home/samba/share/test/

# setsebool -P samba_export_all_ro=1 samba_export_all_rw=1
# 這句有錯(cuò)getsebool –a | grep samba_export
# semanage fcontext –at samba_share_t "/home/samba/share/test(/.*)?"
# restorecon /home/samba/share/test/
0x04 配置FireWalld
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --reload
0x05 遇到的一些問題
# 將samba設(shè)置為開機(jī)自啟
chkconfig --level 35 smb on             //在3、5級(jí)別上自動(dòng)運(yùn)行samba服務(wù)
# 同這種一樣systemctl enable smb.service
chkconfig --list | grep smb
# 查看selinux狀態(tài)
sestatus
# 臨時(shí)關(guān)閉selinux
setenforce 0
# 永久關(guān)閉selinux,修改如下文件,需要重啟
cat /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
# 關(guān)閉firewalld
systemctl stop firewalld
# samba權(quán)限是共享權(quán)限和用戶權(quán)限的交集
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容