Linux下安裝samba,實現和windows檔案分享權限設定

來源:互聯網
上載者:User

samba適合內網檔案分享權限設定。本教程適合ubuntu/Fedora系統。

1、查看是否已安裝。

# rpm -q samba

package samba is not installed

2、使用yum查詢軟體包

#yum list samba (查詢軟體包,得到可安裝的軟體包:  samba.i686)

3、使用yum安裝 (一路選yes安裝完成)

# yum install samba.i686

啟動

service iptables stop

service smb start

service nmb start  

smbd進程的作用是處理SMB請求包(139連接埠),負責驗證和檔案分享權限設定(重要)。nmdb(137 138連接埠)

systemctl

配置:

查詢安裝了哪些軟體包。

#rpm -qa|grep samba

找設定檔,到common的軟體包。

#rpm -q| samba-common-4.0.3.2 | grep smb.conf

找到了:/etc/samba/smb.conf


備份一下:

#cp samba.conf samba.conf.bak

【global】 全域

workgroup= 指定工作群組或域

server string = 描述

security = 指定安全模式 (share 無許可權驗證,user 有伺服器驗證(預設))

hosts allow = 限定主機訪問 (哪些主機可以訪問,哪些使用者)

使用ip網段  例如: 162.1.2. 

log file = 指定記錄檔存放位置

具體配置:

帶 ; 分號開頭的注釋是有效配置,就是說把分號去掉,在做寫修改就行了。

1、配置hosts

我的配置,允許10.5.82. 網段的

hosts allow = 10.5.82. 

2、security 大家可以自訂配置

【home】段, 共用使用者的宿主目錄

comment = 描述 

browseable = no (沒有許可權訪問的目錄,不可見)

writable = yes 


3、需要先添加使用者:

adduser sambatest

添加的samda使用者必須是系統使用者。

assdb backend = tdbsam passdb backend即使用者後台。有三種後台:smbpasswd、tdbsam和ldapsam。
Sam即security account manager。
1.        smbpasswd:該方式是使用smb工具smbpasswd給系統使用者(真實使用者或者虛擬使用者)設定一個Samba 密碼,用戶端就用此密碼訪問Samba資源。smbpasswd在/etc/samba中,有時需要手工建立該檔案。
2.        tdbsam:使用資料庫檔案建立使用者資料庫。資料庫檔案叫passdb.tdb,在/etc/samba中。passdb.tdb使用者資料庫可使用smbpasswd –a建立Samba使用者,要建立的Samba使用者必須先是系統使用者。也可使用pdbedit建立Samba賬戶。pdbedit參數很多,列出幾個主要的:
pdbedit –a username:建立Samba賬戶。
pdbedit –x username:刪除Samba賬戶。
pdbedit –L:列出Samba使用者列表,讀取passdb.tdb資料庫檔案。
pdbedit –Lv:列出Samba使用者列表詳細資料。
pdbedit –c “[D]” –u username:暫停該Samba使用者帳號。
pdbedit –c “[]” –u username:恢複該Samba使用者帳號。
3.        ldapsam:基於LDAP賬戶管理方式驗證使用者。首先要建立LDAP服務,設定“passdb backend = ldapsam:ldap://LDAP Server”


通過windows來訪問:

在運行中輸入:\\linux地址

\\192.168.175.130

會彈出對話方塊,輸入使用者名稱和密碼。

登入成功後如果不能訪問:

#setsebool -P samba_enable_home_dirs on

[global]workgroup = MYGROUPserver string = Samba Server Version %v;netbios name = MYSERVER;interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24hosts allow = 127. 192.168.12. 192.168.13. 10.5.82. 192.168. 10.5.# logs split per machinelog file = /var/log/samba/log.%m# max 50KB per log file, then rotatemax log size = 50security = user;passdb backend = tdbsam;security = domain;passdb backend = tdbsam;realm = MY_REALM;password server = <NT-Server-Name>;security = user;passdb backend = tdbsam;domain master = yes ;domain logons = yes# the login script name depends on the machine name;logon script = %m.bat# the login script name depends on the unix user used;logon script = %u.bat;logon path = \\%L\Profiles\%u# disables profiles support by specifing an empty path;logon path =          ;add user script = /usr/sbin/useradd "%u" -n -g users;add group script = /usr/sbin/groupadd "%g";add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u";delete user script = /usr/sbin/userdel "%u";delete user from group script = /usr/sbin/userdel "%u" "%g";delete group script = /usr/sbin/groupdel "%g";local master = no;os level = 33;preferred master = yes;wins support = yes;wins server = w.x.y.z;wins proxy = yes;dns proxy = yesload printers = yescups options = raw;printcap name = /etc/printcap#obtain list of printers automatically on SystemV;printcap name = lpstat;printing = cups;map archive = no;map hidden = no;map read only = no;map system = no;store dos attributes = yes[homes]comment = Home Directoriesbrowseable = nowritable = yes;valid users = %S;valid users = MYDOMAIN\%S[printers]comment = All Printerspath = /var/spool/sambabrowseable = noguest ok = yeswritable = yesprintable = yes;[netlogon];comment = Network Logon Service;path = /var/lib/samba/netlogon;guest ok = yes;writable = no;share modes = no;[Profiles];path = /var/lib/samba/profiles;browseable = no;guest ok = yes;[public];comment = Public Stuff;path = /home/samba;public = yes;writable = yes;printable = no;write list = +staff[myshare]comment = gaotong's filespath = /home/sharepublic = yeswirtable = yesprintable = no
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.