CentOS中設定Windows共用資料夾

來源:互聯網
上載者:User

標籤:samba伺服器   地址   api   efs   data   完全   comm   com   dos   

 在CentOS中設定Samba可實現和Windows共用資料夾。常見的需求:
1)使用者能夠在Windows機器上通過共用資料夾訪問遠程Linux伺服器上自己的主目錄;
2)使用者能夠在Windows機器上訪問一個項目組或一個部門共用的檔案夾,對檔案夾中的檔案夾具有完全讀寫權限。
要實現上述需求,步驟如下:

1、伺服器安裝Samba組件

[[email protected] ~]# yum install samba.x86_64

2、配置Samba伺服器

編輯Samba伺服器設定檔/etc/samba/smb.conf,在[global]和[public]節中增加如下設定:
[global]

workgroup = WORKGROUP
security = user
display charset = utf8
unix charset = utf8
dos charset = cp936

[public]

comment = data
path = /home/cb/data
browseable= yes
create mode= 0664
directory mode=0775
writable = yes
write list = @cb

配置完之後,檢查配置
[[email protected] ~]# testparam

3、配置Samba使用者

具體需求:
1)使用者cb能夠遠程通過Windows共用資料夾訪問自己的主目錄;
2)除了使用者cb, 將/home/cb/data目錄共用給fxd、wh兩個使用者

[[email protected] ~]$ chmod g+rwx /home/cb            //允許cb組中的使用者對主目錄有rwx許可權

[[email protected] ~]$ mkdir data
[[email protected] ~]$ chmod g+s data/ //Samba共用目錄通常要設定GID屬性
[[email protected] ~]$ chmod o-rwx data///去掉其它使用者對共用目錄的存取權限
[[email protected] ~]$ ls -ld data/
drwxrws---. 2 cb cb 4096 10月 4 00:15 data/

[[email protected] ~]# useradd -G cb fxd//建立使用者fxd
[[email protected] ~]# passwd fxd
[[email protected] ~]# useradd -G cb wh//建立使用者wh
[[email protected] ~]# passwd wh
[[email protected] ~]# pdbedit -a -u cb//增加Samba使用者cb,必須是Linux系統使用者
[[email protected] ~]# pdbedit -a -u fxd//增加Samba使用者fxd,必須是Linux系統使用者
[[email protected] ~] # pdbedit -a -u wh//增加Samba使用者wh,必須是Linux系統使用者
[[email protected] ~]# pdbedit -L
cb:500:chenbin
fxd:502:
wh:503:

4、設定SELinux

[[email protected] home]# getsebool -a |grep samba //設定SELinux關於Samba的布爾值
bacula_use_samba --> off
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off //要共用主目錄,或主目錄下的子目錄,需要開啟該項
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off

[[email protected] home]# setsebool -P samba_enable_home_dirs 1

5、啟動Samba服務

[[email protected] home]# /etc/init.d/smb restart
關閉 SMB 服務: [確定]
啟動 SMB 服務: [確定]
[[email protected] home]# /etc/init.d/nmb restart
關閉 NMB 服務: [確定]
啟動 NMB 服務: [確定]

6、在Windows中測試

在Windows中開啟"運行"對話方塊,輸入: \\共用資料夾所在機器的IP地址,確定後彈出登入對話方塊,輸入Samba使用者名稱和密碼(如: fxd/4321),顯示已共用的檔案夾,,點擊共用資料夾,看是否能正常進入。進入共用資料夾後,測試能否進行檔案的正常讀寫。注意:有時共用資料夾需要滑鼠雙擊兩次才能正常進入,第一次會報錯而不能進入,再次雙擊會正常進入,不知什麼原因。

=-=-=-=-=
Powered by Blogilo

CentOS中設定Windows共用資料夾

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.