The NoteBook of EricKong

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks
          CentOS 6.0 Samba服務器配置

          一、安裝前準備
          1、使用Samba服務器需要防火墻開放以下端口
              UDP 137 UDP 138 TCP 139 TCP 445
          #配置防火墻端口
          [root@roothomes ~] vi /etc/sysconfig/iptables   
          -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
          -A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
          -A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
          -A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
          #重啟防火墻,使規則生效
          [root@roothomes ~] /etc/rc.d/init.d/iptables restart     

          2、關閉CentOS6系統的 SELinux
          [root@roothomes ~] vi /etc/selinux/config
          #SELINUX=enforcing     #注釋掉
          #SELINUXTYPE=targeted  #注釋掉
          SELINUX=disabled       #增加
          #:wq  保存。
          #重啟系統
          [root@roothomes ~] shutdown -r now  或者 init 6

          二、安裝Samba
          1、檢查Samba服務包是否已安裝
          [root@roothomes ~] rpm -qa | grep samba
              samba-3.5.4-68.el6.x86_64
              samba-common-3.5.4-68.el6.x86_64
              samba-client-3.5.4-68.el6.x86_64
              samba4-libs-4.0.0-23.alpha11.el6.x86_64
              samba-winbind-clients-3.5.4-68.el6.x86_64

             說明samba已經安裝,如果沒有安裝,運行下面命令安裝 [root@roothomes ~] yum install samba 
             
          2、配置samba
          [root@roothomes ~] chkconfig smb on  #設置 Samba開機自動啟動
          [root@roothomes ~] service smb start      #啟動Samba服務 
          [root@roothomes ~] /etc/init.d/smb restart  #重啟
          [root@roothomes ~] /etc/init.d/smb stop    #停止 
          [root@roothomes ~] cp /etc/samba/smb.conf  /etc/samba/bak_smb.conf_bak  #備份
          [root@roothomes ~] cp /etc/samba/bak_smb.conf_bak  /etc/samba/smb.conf  #恢復
          [root@roothomes ~] vi /etc/samba/smb.conf
          [global]                           #找到這一行(全局設置標簽),在此行下面添加如下行:
              workgroup = WORKGROUP          #工作組名稱改為 Windows 網絡所定義的工作組名
              server string = Samba Server   #設置samba服務器的主機名稱
              security = user                #設置samba服務器安全級別為user,即以賬號和口令訪問
              netbios name = SambaServer     #設置Samba服務器訪問別名
          #在配置文件的末尾添加以下自定義內容
          [SambaServer]                      #在Windows網上鄰居中看到的共享目錄的名字
              comment = SambaServer          #在Windows網上鄰居中看到的共享目錄的備注信息
              path = /home/SambaServer       #共享目錄在系統中的位置
              public = no                    #不公開目錄
              writable = yes                 #共享目錄可以讀寫
              valid users=SambaServer        #只允許SambaServer用戶訪問
          #保存配置

          3、添加訪問linux共享目錄的賬號SambaServer
             用戶家目錄為/home/SambaServer, 用戶登錄終端設為/bin/false(即使之不能登錄系統)
          [root@roothomes ~] mkdir -p /home/SambaServer #建立SambaServer文件夾
          [root@roothomes ~] cd /home/SambaServer
          [root@roothomes ~] touch  samba.txt   #創建測試文件samba.txt
          [root@roothomes ~] useradd SambaServer -d /home/SambaServer -s /bin/false
          [root@roothomes ~] chown SambaServer:SambaServer /home/SambaServer -R

          4、將用戶SambaServer添加入到Samba用戶數據庫,并設置登錄共享目錄的密碼為:123456
          [root@roothomes ~] smbpasswd -a SambaServer
             New SMB password:  輸入該用戶用于登錄Samba的密碼
             Retype new SMB password:  再次確認輸入該密碼
             Added user SambaServer.
          #備注:這里設置的密碼是SambaServer用戶登錄該機的Samba共享的密碼,非登陸OS的密碼;
          5、重啟Samba服務器
          [root@roothomes ~] /etc/init.d/smb restart
          6、瀏覽共享信息
          在Windows客戶端輸入 \\ip  或者 \\SambaServer  #服務器別名
             回車之后,會跳出來登錄框,輸入賬號SambaServer ,密碼123456 , 即可訪問共享目錄

          至此,CentOS 6.0 linux samba服務器配置完成。

          可以登錄samba服務器,但是沒有權限訪問linux下的共享目錄

          1、確保linux下防火墻關閉或者是開放共享目錄權限  iptalbes -F
          2、確保samba服務器配置文件smb.conf設置沒有問題,可網上查閱資料看配置辦法
          3、確保setlinux關閉,可以用setenforce 0命令執行。 默認的,SELinux禁止網絡上對Samba服務器上的共享目錄進行寫操作,即使你在smb.conf中允許了這項操作。

          這兩個命令必須執行啊:
             iptables -F
             setenforce 0:

          問題:
          如果無法訪問共享目錄的內容,請把防火墻停止;
          [root@roothomes ~] service iptables stop
           
          posted on 2013-06-16 21:57 Eric_jiang 閱讀(380) 評論(0)  編輯  收藏 所屬分類: CentOS
          主站蜘蛛池模板: 梓潼县| 海阳市| 新宾| 阳新县| 中方县| 松阳县| 巩留县| 南阳市| 黔江区| 怀来县| 洛阳市| 格尔木市| 五原县| 太仆寺旗| 广南县| 富源县| 洛阳市| 德化县| 宁城县| 穆棱市| 如皋市| 怀来县| 会泽县| 祁阳县| 呼玛县| 石屏县| 肥西县| 大邑县| 昆山市| 福泉市| 深水埗区| 荆州市| 施秉县| 金平| 淄博市| 乌鲁木齐县| 连山| 哈密市| 涞水县| 密山市| 绍兴县|