紅帽54搭建samba伺服器
㈠ 怎樣在linux系統搭建Samba共享伺服器
Linux系統默認已經安裝了Samba,但是沒有安裝Samba服務: 1,先查看安裝情況:rpm -qa|grep samba 根據系統的安裝情況選擇下載或者通過光碟機安裝所缺的rpm包。 我的安裝情況是: 使用命令:mount /dev/cdrom1 /mnt/cdrom1 通過mount把cdrom1掛載到系統臨時目錄/mnt/cdrom1,在Packets包下面使用命令:rpm -ivh samba.*.rpm包安裝。 切換到放置rpm文件的目錄 [root@smb_server root]# rpm -ivh samba-common-3.6.9-151.el6.x86_64 這是Samba 必備的程序,必須安裝 [root@smb_server root]# rpm -ivh samba-3.6.9-151.el6.x86_64 安裝Samba 伺服器程序,可以使我Windows 主機訪問Samba 伺服器共享的資源。 如果需要使Linux 主機訪問Windows 主機上的共享資源,則還應該安裝Samba 客戶端程序。 [root@smb_server root]# rpm -ivh samba-client-3.6.9-151.el6.x86_64 2,安裝samba的rpm包完成後 samba-common-3.6.9-151.el6.x86_64 //主要提供samba伺服器的設置文件與設置文件語法檢驗程序testparm samba-client-3.6.9-151.el6.x86_64 //客戶端軟體,主要提供linux主機作為客戶端時,所需要的工具指令集 samba-swat-3.6.9-151.el6.x86_64 //基於https協議的samba伺服器web配置界面 samba-3.6.9-151.el6.x86_64 //伺服器端軟體,主要提供samba伺服器的守護程序,共享文檔,日誌的輪替,開機默認選項 Samba伺服器安裝完畢,會生成配置文件目錄/etc/samba和其它一些samba可執行命令工具,/etc/samba/smb.conf是samba的核心配置文件,/etc/init.d/smb是samba的啟動/關閉文件。 5、查看samba的服務啟動情況 # service smb status 6、設置開機自啟動 # chkconfig --level 35 smb on //在3、5級別上自動運行samba服務 7、配置smb服務 [global] workgroup = WORKGROUP server string = Samba Server Version %v netbios name = ImgPath05 [ImgPath] comment = Public stuff path = /usr/local/nginx/html/img public = yes writeable = yes browseable = yes guest ok = yes 共享目錄為:/usr/local/nginx/html/img,共享目錄對外名稱為:ImgPath 即在Windows看到的目錄名稱。 設置共享目錄許可權:chown -R nobody:nobody /usr/local/nginx/html/img/ 8、啟動或者重啟smb服務 重啟smb服務 測試smb.conf配置是否正確 9 Windows訪問共享目錄,但是沒有寫許可權,通過以下方式修改防火牆設置。 將Linux smb服務添加到防火牆的例外中 以root用戶執行setup命令#setup彈出...重啟生效,如果不想重啟,用命令#setenforce 0
㈡ redhat enterprise 如何配置samba伺服器
/etc/samba/smb.conf主配置文件,此文件中有豐富的說明注釋
使用smbpasswd命令使Linux系統用戶成為Samba用戶,命令格式如下:
smbpasswd –a 用戶名
SMB.CONF具體實例
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not many any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]
# workgroup = NT-Domain-Name or Workgroup-Name
workgroup = Workgroup ;計算機所在的工作組名或域名
netbios name = fileserver ;即在,網上鄰居中顯示的計算機名
# server string is the equivalent of the NT Description field
server string = Samba Server ;計算機描述
This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
; hosts allow = 192.168.1. 192.168.2. 127. ;允許訪問的計算機的IP地址
; hosts allow = 172.16.0. 172.16.3. 127.
# if you want to automatically load your printer list rather
# than setting them up indivially then you'll need this
; printcap name = /etc/printcap載入列印機的配置路徑
load printers = no是否將列印機共享
# It should not be necessary to spell out the print system type unless
# yours is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx
; printing = cups一種列印驅動模式,即LINUX支持的標准列印類型。其LINUX支持的列印類型有bsd, sysv, plp, lprng, aix, hpux, qnx
# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
; guest account = nobody
guest account = guest ;允許訪問(不需要用戶名與密碼)也可以指定任何系統內置的一個帳號做為來賓帳號。
# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log.會給用戶在此目錄下做每個SAMBA用戶登錄的日誌。
# Put a capping on the size of the log files (in Kb).
max log size = 50日誌 文件限制在50K內
# Security mode. Most people will want user level security. See
# security_level.txt for details.
security = share
; security = user
# Use password server option only with security = server
; password server = <NT-Server-Name>此行的作用為如果上面的選項為SERVER,則SAMBA伺服器在做身份識別的時候,把WIN機器發過來的密碼同用戶名交給此項設定的密碼伺服器驗證。
# Password Level allows matching of _n_ characters of the password for
# all combinations of upper and lower case.
; password level = 8
; username level = 8(對於從前的幾款老式的WINDOWS系統對於大小寫密碼支持的不是很好,所以開啟上面的兩個參數的意義是在密碼為8位的用戶名與密碼的帳號里自動匹配所有的大小寫測試)
# You may wish to use password encryption. Please read
# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
# Do not enable this option unless you have read those documents
encrypt passwords = yes(加密明文的SAMBA密碼進行發送)
smb passwd file = /etc/samba/smbpasswd驗證密碼所在的目錄
# The following are needed to allow password changing from Windows to
# update the Linux sytsem password also.
# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.
# NOTE2: You do NOT need these to allow workstations to change only
# the encrypted SMB passwords. They allow the Unix password
# to be kept in sync with the SMB password.
# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
; wins support = yes把該伺服器配置為WINS伺服器
# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = 192.168.1.100也可以指定一個WINS伺服器,讓自己成為WINS客戶
# WINS Proxy - Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one WINS Server on the network. The default is NO.
; wins proxy = yes(針對老式計算機,不用設置)
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The built-in default for versions 1.9.17 is yes,
# this has been changed in version 1.9.18 to no.
dns proxy = no(針對老式計算機,不用設置)
# Case Preservation can be handy - system default is _no_
# NOTE: These can be set on a per share basis
; preserve case = no
; short preserve case = no
# Default case is normally upper case for all DOS files
; default case = lower
# Be very careful with case sensitivity - it can break things!
; case sensitive = no
(整個上面這段為討論與WINDWOS文件系統的大小寫問題因為微軟的系統是一個大小寫不區分 的系統,默認用默認值即可。因為修改可能造成與WINDOWS的不兼容問題)
#============================ Share Definitions ==============================
[homes]作為登錄用戶,自己訪問自己目錄的設置。
; comment = Home Directories目錄說明
; browseable = no用戶私人目錄不需要給別人瀏覽。
; writable = yes也可以用read only=no來替代
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]域用戶登錄目錄設置。
; comment = Network Logon Service
; path = /home/netlogon
; guest ok = yes
; writable = no
; share modes = no
# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;[Profiles]
; path = /home/profiles
; browseable = no
; guest ok = yes
# NOTE: If you have a BSD-style print system there is no need to
# specifically define each indivial printer
[printers]列印機共享
comment = All Printers說明共享全部列印機
path = /var/spool/samba列印機池,用戶必須手工創建該目錄。
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
printable = yes用戶是否可以列印
# This one is useful for people to share files
;[tmp]
; comment = Temporary file space
; path = /tmp
; read only = no可以寫入
; public = yes即目錄是否共享給來賓帳號。
# A publicly accessible directory, but read only, except for people in
# the "staff" group
[public]
comment = Public Stuff
path = /home/soft
public = yes
guest ok = yes以上兩個public=yes代表來賓帳號能訪問此共享目錄,但guest ok代表密碼不是必須的,可以不加。
writable = yes
printable = no
write list = @staff此參數告訴我們不必要讓所有人訪問共享目錄,可以有staff這個組的成員能訪問,但在passwd和shadow文件中要存在這個組。
# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# home directory. Note that fred must have write access to the spool directory,
# wherever it is.
;[fredsprn](設置僅供一人使用的共享列印機)
; comment = Fred's Printer;
valid users = fred
; path = /homes/fred
; printer = freds_printer
; public = no
; writable = no
; printable = yes
# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir] (為創建一個私有目錄,別人都不能訪問,只有fred這個用戶能訪問)
; comment = Fred's Service
; path = /usr/somewhere/private
; valid users = fred
; public = no
; writable = yes
; printable = no
# a service which has a different directory for each machine that connects
# this allows you to tailor configurations to incoming machines. You could
# also use the %u option to tailor it by user name.
# The %m gets replaced with the machine name that is connecting.
;[pchome]
; comment = PC Directories
; path = /usr/pc/%m
; public = no
; writable = yes
# A publicly accessible directory, read/write to all users. Note that all files
# created in the directory by users will be owned by the default user, so
# any user with access can delete any other user's files. Obviously this
# directory must be writable by the default user. Another user could of course
# be specified, in which case all files would be owned by that user instead.
;[public]
; path = /usr/somewhere/else/public
; public = yes
; only guest = yes
; writable = yes
; printable = no
# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
;[myshare]這個例子是配置一個僅供兩個用戶訪問的目錄
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
; valid users = mary fred
; public = no
; writable = yes
; printable = no
; create mask = 0765
最後建議在圖形界面配置比較簡單
在LINUX提示符下輸入startx
即可進入圖形界面 和WINDOWS差不多 窗口化的配置比較直觀也比較簡單
㈢ 在紅帽企業版5下裝samba伺服器時出現
yum install samba
用yum,解決依賴問題。
不過,你要可以聯網。
㈣ 我在紅帽linux5中搭建samba伺服器,win7下共享界面卻出不來,能教教我嗎
1.首先確定samba服務是否運行,smb和nmb兩個進程。
2.看一下伺服器samba配置文件/etc/samba/smb.conf的workgroup,它必須與Win的工作組一致,一般Win的工作組是WORKGROUP。
3.看配置文件里的interfaces是否正確,hosts allow的ip段是否覆蓋Win的ip地址。
4.伺服器上啟用user安全級別時,是否添加了共享用戶,是否允許共享用戶瀏覽。
5.防火牆的規則設置是否正確。
6.SELinux是否阻止你訪問samba共享的目錄。
㈤ 如何搭建samba伺服器
samba安裝和啟動
samba的源碼安裝採用最新版本samba-4.1.14,官網下載。安裝過程如下:
$ sudo mkdir /usr/local/samba-4.1.14
$ ./configure --prefix=/usr/local/samba-4.1.14
...
Checking for program xsltproc : not found
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for Python version >= 2.5.0 : ok 2.7.6
Checking for library python2.7 : not found
Checking for library python2.7 : yes
Checking for program python2.7-config : not found
Checking for program python-config-2.7 : not found
Checking
for custom code
: Could not find the python development headers
/home/anonymalias/Downloads/samba-4.1.14/wscript:100:
error: the configuration failed (see
'/home/anonymalias/Downloads/samba-4.1.14/bin/config.log')
上面錯誤的原因是samba必須依賴python,執行
$ sudo apt-get install python-dev
後面就是make && sudo make install,安裝ok後,安裝目錄結構如下:
/usr/local/samba-4.1.14$ ls
bin etc include lib private sbin share va
將源碼文件下默認的conf文件拷貝到安裝目錄下的etc目錄中
/usr/local/samba-4.1.14$ cp /home/anonymalias/Downloads/samba-4.1.14/examples/smb.conf.default etc/smb.conf
修改smb.conf中配置
global段添加如下欄位
[global]
...
netbios name = ubuntu
共享資源欄位採用默認配置
[homes]
comment = Home Directories
browseable = no
writable = yes
# NOTE: If you have a BSD-style print system there is no need to
# specifically define each indivial printer
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
printable = yes
添加用戶名為Ubuntu的賬戶,
/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a ubuntu
New SMB password:
Retype new SMB password:
samba伺服器的用戶是依賴於linux的用戶,只能添加linux中已存在的用戶,否則會出現如下錯誤:
/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a user1
New SMB password:
Retype new SMB password:
Failed to add entry for user user1.
啟動samba 服務
/usr/local/samba-4.1.14$ sudo sbin/nmbd
/usr/local/samba-4.1.14$ sudo sbin/smbd
在Windwos文件管理器或直接win+R,輸入server ip,可以看到如下界面:
㈥ 如何在RedHat中安裝samba
為了實現Windows主機與Linux伺服器之間的資源共享,Linux操作系統提供了Samba服務,Samba服務為兩種不同的操作系統架起了一座橋梁,使Linux系統和Windows系統之間能夠實現互相通信,為廣泛的Linux愛好者提供了極大方便。本文簡要介紹如何在Linux操作系統上搭建Samba伺服器和簡單配置。
1、服務查詢
默認情況下,Linux系統在默認安裝中已經安裝了Samba服務包的一部分 ,為了對整個過程有一個完整的了解,在此先將這部分卸載掉。使用命令
rpm -qa | grep samba ,默認情況下可以查詢到兩個已經存在的包:
samba-client-3.0.33-3.7.el5
samba-common-3.0.33-3.7.el5
2、卸載Samba
用rpm -e 將兩個包卸載掉。對於samba-common-3.0.33-3.7.el5,因為與其它rpm包之間存在依賴關系,所以必須加參數-f和--nodeps,-f是指強制,--nodeps是指不檢查依賴關系,具體完整命令為:
rpm -e samba-common-3.0.33-3.7.el5 -f --nodeps
rpm -e samba-client-3.0.33-3.7.el5 -f --nodeps
3、安裝Samba
用以下命令安裝:
rpm -ivh samba-3.0.33-3.29.el5_6.2.i386.rpm -f --nodeps
rpm -ivh samba-client-3.0.33-3.29.el5_6.2.i386.rpm -f --nodeps
rpm -ivh samba-common-3.0.33-3.29.el5_6.2.i386.rpm -f --nodeps
安裝完成後,使用命令rpm -qa | grep samba進行查詢,發現搭建samba伺服器所依賴的所有伺服器都已經安裝好了即可。
4、配置smb.conf文件
Samba的配置文件一般就放在/etc/samba目錄中,主配置文件名為smb.conf,文件中記錄著大量的規則和共享信息,所以是samba服務非常重要的核心配置文件,完成samba伺服器搭建的大部分主要配置都在該文件中進行。
Samba伺服器的工作原理是:客戶端向Samba伺服器發起請求,請求訪問共享目錄,Samba伺服器接收請求,查詢smb.conf文件,查看共享目錄是否存在,以及來訪者的訪問許可權,如果來訪者具有相應的許可權,則允許客戶端訪問,最後將訪問過程中系統的信息以及採集的用戶訪問行為信息存放在日誌文件中。
第一步:修改配置文件
首先備份一下samba的配置文件
cd /etc/samba
mv smb.conf smb.confbak
然後重新創建一個smb.conf文件
touch smb.conf
然後我們把這段寫入smb.conf中
[global]
workgroup = LinuxSir
netbios name = LinuxSir05
server string = Linux Samba Server TestServer
security = share
[linuxsir]
path = /opt/linuxsir
writeable = yes
browseable = yes
guest ok = yes
註解:
[global]這段是全局配置,是必段寫的。其中有如下的幾行;
workgroup 就是Windows中顯示的工作組;在這里我設置的是LINUXSIR (用大寫);
netbios name 就是在Windows中顯示出來的計算機名;
server string 就是Samba伺服器說明,可以自己來定義;這個不是什麼重要的;
security 這是驗證和登錄方式,這里我們用了share ;驗證方式有好多種,這是其中一種;另外一種常用的是user的驗證方式;如果用share呢,就是不用設置用戶和密碼了;
[linuxsir] 這個在Windows中顯示出來是共享的目錄;
path = 可以設置要共享的目錄放在哪裡;
writeable 是否可寫,這里我設置為可寫;
browseable 是否可以瀏覽,可以;可以瀏覽意味著,我們在工作組下能看到共享文件夾。如果您不想顯示出來,那就設置為 browseable=no
guest ok 匿名用戶以guest身份是登錄;
第二步:建立相應目錄並授權;
[root@localhost ~]# mkdir -p /opt/linuxsir
[root@localhost ~]# id nobody
uid=99(nobody) gid=99(nobody) groups=99(nobody)
[root@localhost ~]# chown -R nobody:nobody /opt/linuxsir
注釋:
關於授權nobody,我們先用id命令查看了nobody用戶的信息,發現他的用戶組也是nobody,我們要以這個為准。有些系統nobody用戶組並非是nobody ;
第三步:啟動smbd和nmbd伺服器;
[root@localhost ~]# smbd
[root@localhost ~]# nmbd
㈦ 主機win7,虛擬機里安裝的是紅帽linux5,怎樣在圖形界面啟動samba服務;
許可權在/etc/samba/smb.conf裡面配置,比如你共享的文件夾是/home/share,
[home]
path = /home/share
在後面設置許可權writeable = yes(寫許可權)
保存後重啟samba,如果還是不行那可能是selinux的問題,你打開smb.conf,在開頭注釋裡面
有這樣兩行:setsebool -P samba_domain_controller on;setsebool -P samba_enable_home_dirs on,拿到shell裡面去執行一下再重啟samba 試試
linux查看win7的共享要用smbclient命令,前提是安裝了smb客戶端
㈧ 如何配置samba伺服器
1、安裝有關Samba的RPM包(samba、samba-common、samba-client)
2、創建Samba用戶
3、修改配置文件
4、重啟samba服務
5、設置目錄訪問許可權
6、測試
具體步驟如下:
1、安裝RPM包(預設情況下RHEL5安裝了samba的相關軟體包,可以用如下命令查看)
[root@localhost ~]#rpm -qa | grep samba
samba -----samba伺服器程序的所有文件
samba-common -----提供了Samba伺服器和客戶機中都必須使用的公共文件
samba-client -----提供了Samba客戶機的所有文件
samba-swat -----以Web界面的形式提供了對Samba伺服器的管理功能
2、創建samba用戶
[root@localhost ~]#smbpasswd -a user1 (「-a」是創建samba用戶,「-x」是刪 [root@localhost ~]#smbpasswd -a user2 除samba用戶,「-d」是禁用samba用
[root@localhost ~]#smbpasswd -a user3 戶帳號,「-e」是啟用samba用戶帳號)
3、修改配置文件
samba配置文件的位置:/etc/samba/smb.conf
[root@localhost ~]#vim /etc/samba/smb.conf
Vi大開配置文件後,首先介紹一下Samba伺服器的安全級別,如圖所示:系統默認設置「user」
Samba伺服器的安全級別分為5種,分別是user、share、server、domain和ads。在設置不同的級別時,samba伺服器還會使用口令伺服器和加密口令。
1、user -----客戶端訪問伺服器時需要輸入用戶名和密碼,通過驗證後,才能使用伺服器的共享資源。此級別使用加密的方式傳送密碼。
2、share -----客戶端連接伺服器時不需要輸入用戶名和密碼
3、server -----客戶端在訪問時同樣需要輸入用戶名和密碼,但是,密碼驗證需要密碼驗證伺服器來負責。
4、domain -----採用域控制器對用戶進行身份驗證
5、ads -----若samba伺服器加入到Windows活動目錄中,則使用ads安全級別,ads安全級別也必須指定口令伺服器
共享目錄的配置
[homes] -----samba用戶的宿主目錄
comment = Home Directories -----設置共享的說明信息
browseable = no -----目錄瀏覽許可權
writable = yes -----用戶對共享目錄可寫
這個共享目錄只有用戶本身可以使用,默認情況下,用戶主目錄位於/home目錄下,每個Linux用戶有一個以用戶名命名的子目錄。
以下是共享列印機的設置:
[printers] -----共享列印機
comment = All Printers -----設置共享的說明信息
path = /var/spool/samba -----指定共享目錄的路徑
browseable = no -----目錄瀏覽許可權
guest ok = no -----允許來賓訪問
writable = no -----用戶對共享目錄可寫
printable = yes -----可以列印
以上是系統默認設置
添加自定義的共享目錄:( user1對/ASUS有所有權,user2擁有隻讀許可權,其他用戶不能訪問;public共享目錄允許所有用戶訪問及上傳文件)
[ASUS]
comment = user1 Directories -----設置共享的說明信息
browseable = yes -----所有samba用戶都可以看到該目錄
writable = yes -----用戶對共享目錄可寫
path = /ASUS -----指定共享目錄的路徑
[public]
comment = all user Directories -----設置共享的說明信息
browseable = yes -----所有samba用戶都可以看到該目錄
writable = yes -----用戶對共享目錄可寫
path = /public -----指定共享目錄的路徑
guest ok = yes -----允許來賓訪問
4、修改完配置文件後需要重啟samba服務
[root@localhost ~]#service smb restart
Samba伺服器包括兩個服務程序
2 smbd
? smbd服務程序為客戶機提供了伺服器中共享資源的訪問
2 nmbd
? nmbd服務程序提供了NetBIOS主機名稱的解析,為Windows網路中域或者工作組內的主機進行主機名稱的解析
5、設置目錄許可權
[root@localhost ~]#mkdir /ASUS ------創建要共享目錄
[root@localhost ~]#mkdir /public ------創建要共享的目錄
[root@localhost ~]#chmod 750 /ASUS ------修改/ASUS許可權(屬主擁有
所有權,屬組只讀,其它用戶不能訪問)
[root@localhost ~]#chown user1 /ASUS ------將/ASUS的屬主改為user1
[root@localhost ~]#groupadd ASUS ------添加ASUS組
[root@localhost ~]#usermod –G ASUS user1 ------將user1加入到ASUS組
[root@localhost ~]#usermod –G ASUS user2 ------將user2加入到ASUS組
[root@localhost ~]#chgrp ASUS /ASUS ------將/ASUS的屬組改為
ASUS
[root@localhost ~]#chmod 777 /public ------給所有用戶分配完全控制
許可權
配置完成後,還要檢查/etc/service文件中以「netbios」開頭的記錄,正確的文件
記錄如下所示,如果這些記錄前有#或沒有這些記錄,應手工添加,否則用戶無
法訪問Linux伺服器上的共享資源
6、測試
找一台內網windows客戶端,打開「網上鄰居 」,輸入samba伺服器的IP點擊
「搜索」
如圖所示:已經搜索到
雙擊打開,如圖所示:提示輸入用戶名和密碼,先來輸入user1的用戶名和密碼
作測試。
登錄成功,
打開user1的宿主目錄,此目錄user1是擁有所有許可權的,創建一個目錄測試一
下,如圖所示:可以創建
Public目錄是允許任何用戶上傳、下載及刪除文件,如圖所示
User1對ASUS目錄擁有完全控制許可權,所以user1可以在此目錄下作任何操作
切換另一個用戶測試,由於我們在同一台計算機上作測試,測試之前首先要清楚
計算機上的緩存,如圖所示:打開 「命令提示符模式」,「net use /del *」是清
除計算機上緩存
重新打開網上鄰居,找到Samba 伺服器的共享資源,以user2的身份登錄
以下幾幅圖片可以看到,user2對ASUS目錄擁有隻讀許可權,對public、user2目
錄擁有所有權
再切換一個用戶登錄,記得要清除緩存哦,輸入user3的用戶名及密碼
如圖所示:user3無法訪問ASUS目錄
User3隻對user3和public目錄擁有所有權
㈨ 搭建samba伺服器應該注意什麼
一般你裝系統的時候會默認安裝samba,如果沒有安裝,只需要運行這個命令安裝(CentOS):
「yum install -y samba samba-client」
Samba的配置文件為/etc/samba/smb.conf,通過修改這個配置文件來完成我們的各種需求。打開這個配置文件,你會發現很多內容都用」#」或者」;」注視掉了。先看一下未被注釋掉的部分:
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
主要有以上三個部分:[global], [homes], [printers]。
[global]定義全局的配置,」workgroup」用來定義工作組,相信如果你安裝過windows的系統,你會對這個workgroup不陌生。一般情況下,需要我們把這里的」MYGROUP」改成」WORKGROUP」(windows默認的工作組名字)。
security = user #這里指定samba的安全等級。關於安全等級有四種:
share:用戶不需要賬戶及密碼即可登錄samba伺服器
user:由提供服務的samba伺服器負責檢查賬戶及密碼(默認)
server:檢查賬戶及密碼的工作由另一台windows或samba伺服器負責
domain:指定windows域控制伺服器來驗證用戶的賬戶及密碼。
passdb backend = tdbsam # passdb backend (用戶後台),samba有三種用戶後台:smbpasswd, tdbsam和ldapsam.
smbpasswd:該方式是使用smb工具smbpasswd給系統用戶(真實用戶或者虛擬用戶)設置一個Samba 密碼,客戶端就用此密碼訪問Samba資源。smbpasswd在/etc/samba中,有時需要手工創建該文件。
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用戶賬號。
ldapsam:基於LDAP賬戶管理方式驗證用戶。首先要建立LDAP服務,設置「passdb backend = ldapsam:ldap://LDAP Server」
load printers 和 cups options 兩個參數用來設置列印機相關。
除了這些參數外,還有幾個參數需要你了解:
netbios name = MYSERVER # 設置出現在「網上鄰居」中的主機名
hosts allow = 127. 192.168.12. 192.168.13. # 用來設置允許的主機,如果在前面加」;」則表示允許所有主機
log file = /var/log/samba/%m.log #定義samba的日誌,這里的%m是上面的netbios name
max log size = 50 # 指定日誌的最大容量,單位是K
[homes]該部分內容共享用戶自己的家目錄,也就是說,當用戶登錄到samba伺服器上時實際上是進入到了該用戶的家目錄,用戶登陸後,共享名不是homes而是用戶自己的標識符,對於單純的文件共享的環境來說,這部分可以注視掉。
[printers]該部分內容設置列印機共享。
㈩ 在紅帽linux5中搭建samba伺服器,在win7下共享界面也出來了,但訪問不了
使用虛擬機的吧?
你有給share這個目錄許可權嗎?沒有的話就在linux下輸入命令:chmod 777 share;
如果還解決不了,應該就是samba的配置文件沒配置好,在smb.conf里,要配置好訪問的用戶或用戶組,還要設置相應的許可權,如writable,read only 之類的許可權。