2015年5月6日 星期三

設定 Samba Server

[ 設定 Samba Server ]


1. 安裝
  • rpm -ql samba  (發現並未安裝)
  • 安裝 samba套件
           # yum search samba*  
           # yum list samba*
           # yum install samba
  • cat /etc/sysconfig/i18n       查看伺服器語系是否為utf-8
  • # cd /etc/samba
  • # cp smb.conf smb.conf.raw    備份一份
  • # vim smb.conf
    [global]
          workgroup = MYGROUP
          netbios name = cd2
          security = share    (不須帳密的分享)
          load printers = no
    [temp]
         common  = temporary file space
         path = /tmp
         writable = yes
         browseable = yes
         guest ok = yes
    •  vim 語法:命令模式下    「/搜尋字串」 「nyy,向下複製n行」 「p 貼上」
  •  # testparm   檢查 smb.conf 語法是否有誤
  • ulimit -n 16834
  • /etc/init.d/smb start   (啟動smb)
  • /etc/init.d/nmb start
  • chkconfig smb ok     (設定開機即啟動)
  • chkconfig nmb ok
  • netstat -tlnup | grep mbd
    • 此時會看到 port 137、138、139、445
2. 調整防火牆
  •  # getenforce  查看SElinux 為 enforcing
  •  # setenforce 0  暫時關閉selinux
  •  # /etc/selinux/config  中把 selinux=enforcing 改為 disable (永久關閉)
  •  # service iptables status  查看iptables的狀態
  •  # service iptables stop  暫時關閉防火牆
  •  # chkconfig iptables off 永久關閉防火牆
3. # chmod 775 (777) share的資料夾

4. 設定須要帳號密碼的分享
  • # vim smb.conf
    [global]
          workgroup = MYGROUP
          netbios name = cd2
          security =user
          passdb backend = tdbsam
          load printers = no
    [home]
    [pic]
         common  = share file
         path = /home/pic
         writable = yes
         browseable = yes
         write list = @users
  • # chgrp users /home/pic
  • # chmod 2770 /home/pic
  • # ll -d /home/pic
  • # useradd -G users user  (新增user帳號且為users群組)
  • # passed user
  • # pdbedit -L  (查看samba 資料庫裡的帳號)
  • # pdbedit -a -u user  (新增samba 帳號)
  • # smbpasswd user  (修改samba裡的帳號之密碼)
  • /etc/init.d/smb restart
  • /etc/init.d/nmb restart
  • # smbclient -L //127.0.0.1 -U user