2016年3月29日 星期二

160330 在 CentOS7/RHEL7 上架設 Samba Server

基本設定流程: 
  1. 安裝 Samba Server 套件:
    #yum -y install samba
  2. 設定欲分享目錄:
    #mkdir /sharedpath
  3. 設定 SELinux 限定規則:
    #semanage fcontext -a -t samba_share_t '/sharedpath(/.*)?'
    #restorecon -RFvv /sharedpath
  4. 設定 Samba Server 設定檔:
    #vim /etc/samba/smb.conf
     [global]
      workgroup = WORKGROUP
      interfaces = lo eth0 192.168.1.1/24
      hosts allow = 127. 192.168.1.
     [myshare]
       path = /sharedpath
       writable = no
       valid users = fred, @management
  5. 開啟 SELinux 存取規則:
    #setsebool -P samba_enable_home_dirs=on
    #restorecon -RFvv /sharedpath
  6. 在 Samba Server 上,検查設定項目是否正確:
    #testparm
  7. 在 Samba Server 上,新增一般的使用者帳號與密碼:
    #useradd -s /sbin/nologin fred
  8. 在 Samba Server 上,安裝管理使用者的套件:
    #yum -y install samba-client
  9. 在 Samba Server 上,設定可存取 Samba Server的使用者帳號與密碼:
    #smbpasswd -a fred
  10. 啟動 Samba Server:
    #systemctl start smb nmb
    #systemctl enable smb nmb
  11. 在 Samba Server 上,開啟防火牆設定:
    #firewall-cmd --permanent --add-service=samba
    #firewall-cmd --reload
  12. 在 client 端,掛載 Samba Server 所分享目錄:
    #mkdir /mnt/myshare
    #mount -t cifs -o username=fred //server/myshare /mnt/myshare

沒有留言:

張貼留言