當前位置:首頁 » 操作系統 » linux配置samba伺服器配置

linux配置samba伺服器配置

發布時間: 2022-05-17 06:23:48

linux如何搭建samba服務

主配置文件:

/etc/samba/smb.conf

#=================== Global Settings===============

[global]部分設置,主要就是下列幾項,其餘可以保持不變,當然你要比較復雜高級的功能服務的話,那就另當別論了;

# workgroup = NT-Domain-Name or Workgroup-Name

workgroup = MSHOME #主機所屬工作組名稱

# server string is the equivalent of the NT Description field

server string = Samba Server #SAMBA伺服器主機的注釋,可選,但是建議還是留著,而且盡量寫的詳細准確,有助於識別;

# Security mode. Most people will want user level security. See security_level.txt for details.

security = share #安全模式,由於是共享目錄,所以用share;

#==================== Share Definitions ==========

共享部分設置其它保存不動,直接在最後面添加你要共享的目錄即可,同時要注意其訪問許可權;

[nfs]

path = /var/nfs

public = yes

writable = yes

/var/nfs目錄對所有用戶都可讀可寫;

四、啟動服務

通過以上簡單的設置,重啟服務後,即可在Windows下在網上鄰居中進行訪問;

在FC5下,服務名為smb及nmb,啟動smb時自動將nmb也啟動;

五、注意事項

1、防火牆問題

2、確保共享目錄的訪問許可權

3、通過網上鄰居訪問相應共享目錄前,必須確保目錄在伺服器上存在。

範本:vi /etc/samba/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 made any basic syntactic errors.

#

#======================= Global Settings =====================================

[global]

# workgroup = NT-Domain-Name or Workgroup-Name

workgroup = WORKGROUP

netbios name = rayman_linux

# server string is the equivalent of the NT Description field

server string =Linux Samba Server TestServer

# 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.

# 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 = yes

# 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, cups

printing = cups

# Uncomment this if you want a guest account, you must add this to /etc/passwd

# otherwise the user "nobody" is used

guest account = detack

# this tells Samba to use a separate log file for each machine

# that connects

log file = /var/log/samba/%m.log

# Put a capping on the size of the log files (in Kb).

max log size = 0

# Security mode. Most people will want user level security. See

# security_level.txt for details.

security = share

# Use password server option only with security = server

# The argument list may include:

# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]

# or to auto-locate the domain controller/s

# password server = *

; password server = <NT-Server-Name>

# Password Level allows matching of _n_ characters of the password for

# all combinations of upper and lower case.

; password level = 8

; username level = 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

smb passwd file = /etc/samba/smbpasswd

# The following is needed to keep smbclient from spouting spurious errors

# when Samba is built with support for SSL.

; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt

# The following are needed to allow password changing from Windows to

# update the Linux system 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.

unix password sync = Yes

passwd program = /usr/bin/passwd %u

passwd chat = *New*password* %n\n *Retype*new*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*

# You can use PAM's password change control flag for Samba. If

# enabled, then PAM will be used for password changes when requested

# by an SMB client instead of the program listed in passwd program.

# It should be possible to enable this without changing your passwd

# chat parameter for most setups.

pam password change = yes

# Unix users can map to different SMB User names

; username map = /etc/samba/smbusers

# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting

; include = /etc/samba/smb.conf.%m

# This parameter will control whether or not Samba should obey PAM's

# account and session management directives. The default behavior is

# to use PAM for clear text authentication only and to ignore any

# account or session management. Note that Samba always ignores PAM

# for authentication in the case of encrypt passwords = yes

obey pam restrictions = yes

# Most people will find that this option gives better performance.

# See speed.txt and the manual pages for details

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

# Configure Samba to use multiple interfaces

# If you have multiple network interfaces then you must list them

# here. See the man page for details.

; interfaces = 192.168.12.2/24 192.168.13.2/24

# Configure remote browse list synchronisation here

# request announcement to, or browse list sync from:

# a specific host or from / to a whole subnet (see below)

; remote browse sync = 192.168.3.25 192.168.5.255

# Cause this host to announce itself to local subnets here

; remote announce = 192.168.1.255 192.168.2.44

# Browser Control Options:

# set local master to no if you don't want Samba to become a master

# browser on your network. Otherwise the normal election rules apply

; local master = no

# OS Level determines the precedence of this server in master browser

# elections. The default value should be reasonable

; os level = 33

# Domain Master specifies Samba to be the Domain Master Browser. This

# allows Samba to collate browse lists between subnets. Don't use this

# if you already have a Windows NT domain controller doing this job

; domain master = yes

# Preferred Master causes Samba to force a local browser election on startup

# and gives it a slightly higher chance of winning the election

; preferred master = yes

# Enable this if you want Samba to be a domain logon server for

# Windows95 workstations.

; domain logons = yes

# if you enable domain logons then you may want a per-machine or

# per user logon script

# run a specific logon batch file per workstation (machine)

; logon script = %m.bat

# run a specific logon batch file per username

; logon script = %U.bat

# Where to store roving profiles (only for Win95 and WinNT)

# %L substitutes for this servers netbios name, %U is username

# You must uncomment the [Profiles] share below

; logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:

# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server

; wins support = yes

# 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 = w.x.y.z

# 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

#============================ Share Definitions ==============================

[homes]

comment = Home Directories

browseable = no

writable = yes

valid users = %S

create mode = 0664

directory mode = 0775

# If you want users samba doesn't recognize to be mapped to a guest user

; map to guest = bad user

# Un-comment the following and create the netlogon directory for Domain Logons

; [netlogon]

; comment = Network Logon Service

; path = /usr/local/samba/lib/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 = /usr/local/samba/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/samba

; public = yes

; writable = yes

; printable = no

; write list = @staff

# 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 = /home/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]

; 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/local/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 = /home/detack/app/tomcat

public = yes

browseable = yes

writable = yes

printable = no

guest ok = yes

# 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怎麼配置samba伺服器

1.samba伺服器目錄:
企業數據目錄:/companydata
公共目錄:/companydata/share
銷售部目錄:/companydata/sales
技術部:/companydata/tech
2.企業員工情況:
總經理:gm
銷售部:銷售部經理 redking、員工 sky、員工 jane
技術部:技術部經理 michael、員工 bill、員工 joy
3.搭建samba文件伺服器,建立公共共享目錄,允許所有人訪問,許可權為只讀,為銷售部和技術部分別建立單獨的目錄,只可以總經理和相應部門員工訪問,並且公司員工禁止訪問非本部門的共享目錄。

案例解析:
1.需求分析
對於建立公共目錄public欄位就可以實現匿名訪問,員工只能訪問本部門的共享目錄,禁止訪問非本部門的共享目錄,可以通過設置目錄共享欄位「browseable = no」及欄位「valid users」來實現其隱藏功能和相應的訪問許可權。這樣設置不能很好得解決同一目錄多種需求的許可權設置,所以需要建立獨立配置文件,為每個部門建立一個組後並為每個組建立配置文件來實現隔離用戶許可權會比較靈活。
2. 解決方案
1)建立各部門專用共享目錄
使用mkdir建立需求的共享目錄以便分門別類的存儲相應資料。
[root@RHEL ~]#mkdir /companydata
[root@RHEL ~]#mkdir /companydata/share
[root@RHEL ~]#mkdir /companydata/sales
[root@RHEL ~]#mkdir /companydata/tech
同時設置/companydata共享目錄的用戶許可權
[root@RHEL ~]#chmod –R 777 /companydata
2)添加samba伺服器描述及設置smbpasswd文件
默認/etc/samba/目錄下沒有smbpasswd文件,要先關閉samba的tdbsam驗證。
解決方法:在smb.conf文件中注釋掉passdb backend = tdbsam 一行,為了指定samba用戶的驗證我們加上這一條smb passwd file = /etc/samba/smbpasswd,然後保存退出。
3)添加用戶和組
先建立銷售部組sales,技術部組tech,然後使用useradd命令添加總經理帳號gm及各個員工的帳號並加入相應的用戶組。
[root@RHEL ~]#groupadd sales
[root@RHEL ~]#groupadd tech
[root@RHEL ~]#useradd gm
[root@RHEL ~]#useradd –g sales redking
[root@RHEL ~]#useradd –g sales sky
[root@RHEL ~]#useradd –g sales jane
[root@RHEL ~]#useradd –g tech michael
[root@RHEL ~]#useradd –g tech bill
[root@RHEL ~]#useradd –g tech joy
接著使用smbpasswd命令添加samba用戶:
[root@RHEL ~]#smbpasswd –a gm
New SMB password:
Retype new SMB password:
Added user gm.
[root@RHEL ~]#smbpasswd –a redking
New SMB password:
Retype new SMB password:
Added user reding.
[root@RHEL ~]#smbpasswd –a sky
New SMB password:
Retype new SMB password:
Added user syk.
[root@RHEL ~]#smbpasswd –a jane
New SMB password:
Retype new SMB password:
Added user jane.
[root@RHEL ~]#smbpasswd –a michael
New SMB password:
Retype new SMB password:
Added user michael.
[root@RHEL ~]#smbpasswd –a bill
New SMB password:
Retype new SMB password:
Added user bill.
[root@RHEL ~]#smbpasswd –a joy
New SMB password:
Retype new SMB password:
Added user joy.
4)配置smb.conf文件
(1)建立單獨配置文件
用戶配置文件使用用戶名命令,組配置文件使用組名命令。
[root@RHEL ~]#cp /etc/samba/smb.conf /etc/samba/gm.smb.conf
[root@RHEL ~]#cp /etc/samba/smb.conf /etc/samba/sales.smb.conf
[root@RHEL ~]#cp /etc/samba/smb.conf /etc/samba/tech.smb.conf
(2)設置主配置文件smb.conf
配置smb.conf主配置文件,在global節點中添加相應欄位,確保samba伺服器的主配置文件可以調用獨立的用戶配置文件和組配置文件。
include = /etc/samba/%U.smb.conf表示使samba伺服器載入/etc/samba目錄下格式為「用戶名.smb.conf」的配置文件。
include = /etc/samba/%G.smb.conf表示使samba伺服器載入/etc/samba目錄下格式為「組名.smb.conf」的配置文件。
設置共享目錄/companydata/share
添加如下內容:
[public]
comment=public data
path=/companydata/share
public=yes
5)設置總經理gm配置文件
[root@RHEL ~]#vim /etc/samba/gm.smb.conf
添加如下內容:
[sales]
comment=sales data
path=/companydata/sales
writable=yes
valid users=gm

[tech]
comment=tech data
path=/companydata/tech
writable=yes
valid users=gm
6)設置銷售部組sales配置文件
[root@RHEL ~]#vim /etc/samba/sales.smb.conf
添加如下內容:
[sales]
comment=sales data
path=/companydata/sales
writable=yes
valid users=@sales,gm
7)設置技術部組tech配置文件
[root@RHEL ~]#vim /etc/samba/tech.smb.conf
添加如下內容:
[tech]
comment=tech data
path=/companydata/tech
writable=yes
valid users=@tech,gm
8)開啟samba服務
[root@RHEL ~]#service smb start
9)測試
分別用所設置賬號進行測試。

③ 如何在linux系統下配置samba

通情況能採用root用戶登錄要重新給root用戶設置samba密碼: /usr/local/samba/bin[root@ ~]$ smbpasswd -a root (./smbpasswd -a root)New SMB password:Retype new SMB password:Added user root.重新設置root用戶登錄路徑類其系統(XP、linux)登錄該samba伺服器/usr/local/samba/lib/smb.conf修改設置root用戶登錄路徑:[xgame]path = /data/home/xgamevalid user = xgamewriteable = yespublic = no [root]path = /valid user = rootwriteable = yespublic = yesbrowseable = yes建議做安全
Ubuntu下安裝samba遇到如下問題,如何解決?

sudo apt-get install smbfs
正在讀取軟體包列表... 完成
正在分析軟體包的依賴關系樹
正在讀取狀態信息... 完成
有一些軟體包無法被安裝。如果您用的是 unstable 發行版,這也許是
因為系統無法達到您要求的狀態造成的。該版本中可能會有一些您需要的軟體
包尚未被創建或是它們已被從新到(Incoming)目錄移出。
下列信息可能會對解決問題有所幫助:

下列軟體包有未滿足的依賴關系:
smbfs : 依賴: samba-common (= 3.0.28a-1ubuntu4) 但是 2:4.1.6+dfsg-1ubuntu2.14.04.3 正要被安裝
E: 無法修正錯誤,因為您要求某些軟體包保持現狀,就是它們破壞了軟體包間的依賴關系。

④ linux中samba配置文件怎麼配置

Samba配置文件常用參數詳解

Samba的主配置文件叫smb.conf,默認在/etc/samba/目錄下。
smb.conf含有多個段,每個段由段名開始,直到下個段名。每個段名放在方括弧中間。每段的參數的格式是:名稱=指。配置文件中一行一個段名和參數,段名和參數名不分大小寫。
除了[global]段外,所有的段都可以看作是一個共享資源。段名是該共享資源的名字,段里的參數是該共享資源的屬性。
Samba安裝好後,使用testparm命令可以測試smb.conf配置是否正確。使用testparm –v命令可以詳細的列出smb.conf支持的配置參數。

全局參數:
==================Global Settings ===================
[global]

config file = /usr/local/samba/lib/smb.conf.%m
說明:config file可以讓你使用另一個配置文件來覆蓋預設的配置文件。如果文件 不存在,則該項無效。這個參數很有用,可以使得samba配置更靈活,可以讓一台samba伺服器模擬多台不同配置的伺服器。比如,你想讓PC1(主機名)這台電腦在訪問Samba Server時使用它自己的配置文件,那麼先在/etc/samba/host/下為PC1配置一個名為smb.conf.pc1的文件,然後在smb.conf中加入:config file = /etc/samba/host/smb.conf.%m。這樣當PC1請求連接Samba Server時,smb.conf.%m就被替換成smb.conf.pc1。這樣,對於PC1來說,它所使用的Samba服務就是由smb.conf.pc1定義的,而其他機器訪問Samba Server則還是應用smb.conf。

workgroup = WORKGROUP
說明:設定 Samba Server 所要加入的工作組或者域。

server string = Samba Server Version %v
說明:設定 Samba Server 的注釋,可以是任何字元串,也可以不填。宏%v表示顯示Samba的版本號。

netbios name = smbserver
說明:設置Samba Server的NetBIOS名稱。如果不填,則默認會使用該伺服器的DNS名稱的第一部分。netbios name和workgroup名字不要設置成一樣了。

interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
說明:設置Samba Server監聽哪些網卡,可以寫網卡名,也可以寫該網卡的IP地址。

hosts allow = 127. 192.168.1. 192.168.10.1
說明:表示允許連接到Samba Server的客戶端,多個參數以空格隔開。可以用一個IP表示,也可以用一個網段表示。hosts deny 與hosts allow 剛好相反。
例如:hosts allow=172.17.2.EXCEPT172.17.2.50
表示容許來自172.17.2.*.*的主機連接,但排除172.17.2.50
hosts allow=172.17.2.0/255.255.0.0
表示容許來自172.17.2.0/255.255.0.0子網中的所有主機連接
hosts allow=M1,M2
表示容許來自M1和M2兩台計算機連接
hosts allow=@xq
表示容許來自XQ網域的所有計算機連接

max connections = 0
說明:max connections用來指定連接Samba Server的最大連接數目。如果超出連接數目,則新的連接請求將被拒絕。0表示不限制。

deadtime = 0
說明:deadtime用來設置斷掉一個沒有打開任何文件的連接的時間。單位是分鍾,0代表Samba Server不自動切斷任何連接。

time server = yes/no
說明:time server用來設置讓nmdb成為windows客戶端的時間伺服器。

log file = /var/log/samba/log.%m
說明:設置Samba Server日誌文件的存儲位置以及日誌文件名稱。在文件名後加個宏%m(主機名),表示對每台訪問Samba Server的機器都單獨記錄一個日誌文件。如果pc1、pc2訪問過Samba Server,就會在/var/log/samba目錄下留下log.pc1和log.pc2兩個日誌文件。

max log size = 50
說明:設置Samba Server日誌文件的最大容量,單位為kB,0代表不限制。

security = user
說明:設置用戶訪問Samba Server的驗證方式,一共有四種驗證方式。
1. share:用戶訪問Samba Server不需要提供用戶名和口令, 安全性能較低。
2. user:Samba Server共享目錄只能被授權的用戶訪問,由Samba Server負責檢查賬號和密碼的正確性。賬號和密碼要在本Samba Server中建立。
3. server:依靠其他Windows NT/2000或Samba Server來驗證用戶的賬號和密碼,是一種代理驗證。此種安全模式下,系統管理員可以把所有的Windows用戶和口令集中到一個NT系統上,使用Windows NT進行Samba認證, 遠程伺服器可以自動認證全部用戶和口令,如果認證失敗,Samba將使用用戶級安全模式作為替代的方式。
4. domain:域安全級別,使用主域控制器(PDC)來完成認證。

passdb 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」

encrypt passwords = yes/no
說明:是否將認證密碼加密。因為現在windows操作系統都是使用加密密碼,所以一般要開啟此項。不過配置文件默認已開啟。

smb passwd file = /etc/samba/smbpasswd
說明:用來定義samba用戶的密碼文件。smbpasswd文件如果沒有那就要手工新建。

username map = /etc/samba/smbusers
說明:用來定義用戶名映射,比如可以將root換成administrator、admin等。不過要事先在smbusers文件中定義好。比如:root = administrator admin,這樣就可以用administrator或admin這兩個用戶來代替root登陸Samba Server,更貼近windows用戶的習慣。

guest account = nobody
說明:用來設置guest用戶名。

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
說明:用來設置伺服器和客戶端之間會話的Socket選項,可以優化傳輸速度。

domain master = yes/no
說明:設置Samba伺服器是否要成為網域主瀏覽器,網域主瀏覽器可以管理跨子網域的瀏覽服務。

local master = yes/no
說明:local master用來指定Samba Server是否試圖成為本地網域主瀏覽器。如果設為no,則永遠不會成為本地網域主瀏覽器。但是即使設置為yes,也不等於該Samba Server就能成為主瀏覽器,還需要參加選舉。

preferred master = yes/no
說明:設置Samba Server一開機就強迫進行主瀏覽器選舉,可以提高Samba Server成為本地網域主瀏覽器的機會。如果該參數指定為yes時,最好把domain master也指定為yes。使用該參數時要注意:如果在本Samba Server所在的子網有其他的機器(不論是windows NT還是其他Samba Server)也指定為首要主瀏覽器時,那麼這些機器將會因為爭奪主瀏覽器而在網路上大發廣播,影響網路性能。
如果同一個區域內有多台Samba Server,將上面三個參數設定在一台即可。

os level = 200
說明:設置samba伺服器的os level。該參數決定Samba Server是否有機會成為本地網域的主瀏覽器。os level從0到255,winNT的os level是32,win95/98的os level是1。Windows 2000的os level是64。如果設置為0,則意味著Samba Server將失去瀏覽選擇。如果想讓Samba Server成為PDC,那麼將它的os level值設大些。

domain logons = yes/no
說明:設置Samba Server是否要做為本地域控制器。主域控制器和備份域控制器都需要開啟此項。

logon . = %u.bat
說明:當使用者用windows客戶端登陸,那麼Samba將提供一個登陸檔。如果設置成%u.bat,那麼就要為每個用戶提供一個登陸檔。如果人比較多,那就比較麻煩。可以設置成一個具體的文件名,比如start.bat,那麼用戶登陸後都會去執行start.bat,而不用為每個用戶設定一個登陸檔了。這個文件要放置在[netlogon]的path設置的目錄路徑下。

wins support = yes/no
說明:設置samba伺服器是否提供wins服務。

wins server = wins伺服器IP地址
說明:設置Samba Server是否使用別的wins伺服器提供wins服務。

wins proxy = yes/no
說明:設置Samba Server是否開啟wins代理服務。

dns proxy = yes/no
說明:設置Samba Server是否開啟dns代理服務。

load printers = yes/no
說明:設置是否在啟動Samba時就共享列印機。

printcap name = cups
說明:設置共享列印機的配置文件。

printing = cups
說明:設置Samba共享列印機的類型。現在支持的列印系統有:bsd, sysv, plp, lprng, aix, hpux, qnx

共享參數:
================== Share Definitions ==================
[共享名]

comment = 任意字元串
說明:comment是對該共享的描述,可以是任意字元串。

path = 共享目錄路徑
說明:path用來指定共享目錄的路徑。可以用%u、%m這樣的宏來代替路徑里的unix用戶和客戶機的Netbios名,用宏表示主要用於[homes]共享域。例如:如果我們不打算用home段做為客戶的共享,而是在/home/share/下為每個Linux用戶以他的用戶名建個目錄,作為他的共享目錄,這樣path就可以寫成:path = /home/share/%u; 。用戶在連接到這共享時具體的路徑會被他的用戶名代替,要注意這個用戶名路徑一定要存在,否則,客戶機在訪問時會找不到網路路徑。同樣,如果我們不是以用戶來劃分目錄,而是以客戶機來劃分目錄,為網路上每台可以訪問samba的機器都各自建個以它的netbios名的路徑,作為不同機器的共享資源,就可以這樣寫:path = /home/share/%m 。

browseable = yes/no
說明:browseable用來指定該共享是否可以瀏覽。

writable = yes/no
說明:writable用來指定該共享路徑是否可寫。

available = yes/no
說明:available用來指定該共享資源是否可用。

admin users = 該共享的管理者
說明:admin users用來指定該共享的管理員(對該共享具有完全控制許可權)。在samba 3.0中,如果用戶驗證方式設置成「security=share」時,此項無效。
例如:admin users =bobyuan,jane(多個用戶中間用逗號隔開)。

valid users = 允許訪問該共享的用戶
說明:valid users用來指定允許訪問該共享資源的用戶。
例如:valid users = bobyuan,@bob,@tech(多個用戶或者組中間用逗號隔開,如果要加入一個組就用「@+組名」表示。)

invalid users = 禁止訪問該共享的用戶
說明:invalid users用來指定不允許訪問該共享資源的用戶。
例如:invalid users = root,@bob(多個用戶或者組中間用逗號隔開。)

write list = 允許寫入該共享的用戶
說明:write list用來指定可以在該共享下寫入文件的用戶。
例如:write list = bobyuan,@bob

public = yes/no
說明:public用來指定該共享是否允許guest賬戶訪問。

guest ok = yes/no
說明:意義同「public」。

幾個特殊共享:
[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
; valid users = MYDOMAIN\%S

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = 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

⑤ 怎樣在Linux系統搭建Samba共享伺服器

17.2. 配置 Samba 伺服器 默認的配置文件(/etc/samba/smb.conf)允許用戶作為 Samba 共享來查看他們的 Red Hat Linux 主目錄。它還把為 Red Hat Linux 配置的列印機作為 Samba 共享列印機來共享。換一句話說,你可以在你的 Red Hat Linux 系統上連接列印機,然後從網路上的 Windows 機器來列印。 17.2.1. 圖形化配置 要使用圖形化界面來配置 Samba,使用 Samba 伺服器配置工具。要使用命令行來配置,請跳到第 17.2.2 節。 Samba 伺服器配置工具是用來管理 Samba 共享、用戶、以及基本伺服器設置的圖形化界面。它修改 /etc/samba/ 目錄中的配置文件。沒有使用該程序進行的改變都會被保留。 要使用該程序,你必須在運行 X 窗口系統,具備根特權,並且安裝了 redhat-config-samba RPM 軟體包。要從桌面啟動 Samba 伺服器配置工具,點擊面板上的「主菜單」 => 「系統設置」 => 「伺服器設置」 => 「Samba 伺服器」,或在 shell 提示(如 XTerm 或 GNOME 終端)下鍵入 redhat-config-samba 命令。 圖 17-1. Samba 伺服器配置工具 注記 Samba 伺服器配置工具不顯示允許用戶在 Samba 伺服器上查看他們自己的主目錄的共享列印機或默認文件段。 17.2.1.1. 配置伺服器設置 配置 Samba 伺服器的第一步是配置伺服器的基本設置和幾個安全選項。啟動了應用程序後,選擇 「首選項」 => 「伺服器設置」。「基本」活頁標簽如 圖 17-2所示。 圖 17-2. 配置基本伺服器設置 在「基本」標簽上,指定計算機應在的工作組以及對計算機的簡短描述。它們與 smb.conf 中的 workgroup 和 server string 選項相對應。 圖 17-3. 配置安全伺服器設置 「安全」標簽包含以下選項: 「驗證模式」 — 它和 security 選項相對應。選擇以下驗證模式中的一種。 「域」 — Samba 伺服器依賴於 Windows NT 主要或備份域控制器來校驗用戶。伺服器把用戶名和口令傳遞給控制器,然後等待它們被返回。在「驗證伺服器」欄位中指定主要或備份域控制器的 NetBIOS 名稱。 「加密口令」選項如果被選,它必須被設置為「是」。

⑥ Linux,samba怎麼設置的

#mkdir /public
為了確保拷文件沒問題,修改目錄許可權:
#chmod 777 /public
修改linux虛擬機中的/etc/samba/smb.conf文件,
#vi /etc/samba/smb.conf
新增如下內容:
[public]
path = /public
read only = no
public = yes

修改安全級別,如果對samba用戶知道很少,那麼直接配置成共享級別,修改security後面的內容為share:
security = share

保存退出。
啟動samba服務:
#service smb restart

檢查虛擬機ip地址:
#ifconfig

看到ip地址後,在windows下,點擊「開始」->「運行」->輸入「\\192.168.100.100」,再點擊確定,就能訪問虛擬機共享的public目錄往裡寫文件了了。(上面的192.168.100.100為虛擬機的IP地址)

如果對samba用戶了解的多一些,則為了更安全起見,將安全級別配置成user級別,比上述步驟多出來的步驟就是添加samba用戶。
#useradd testuser
#passwd testuser
首先添加系統用戶,然後配置samba用戶,或者可以直接使用系統已經存在的用戶配置成samba用戶:
#smbpasswd -a testuser
將上述步驟中的security修改為user:
security = user
重啟samba服務:
#service smb restart

用同樣的方式在windows里訪問虛擬機共享目錄時,需要輸入testuser用戶名和用smbpasswd命令設置的密碼,並且對目錄的訪問許可權與testuser用戶在系統里的許可權一致。

⑦ Linux中Samba伺服器的配置

windows訪問linux的samba最方便的方法就是在explorer里用\\<ip
add>給地址,當然你還可以映射網路驅動器,還可以用cmd的net
use命令,用法自己上網找,我給你介紹linux訪問samba的方法。
方法一,最簡單的方法,開個瀏覽器,conqueror或者firefox都行,地址寫smb://<ip
add>
方法二,掛載,命令行是:
mount
-t
cifs
//<ip
add>/<share
name>
/<mount
point>
-o
iocharset=cp936,user
或者用smbmount掛載,用法自己看man,
方法三,smbclient,用法還是自己看man,跟ftp的用法類似。

⑧ 如何配置samba伺服器

這個簡單,可以參考 《鳥哥的linux私房菜 伺服器》 第一個伺服器就是samba伺服器。。具體的來說:

【samba配置文件smb.conf】
一般你裝系統的時候會默認安裝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]該部分內容設置列印機共享。

【samba實踐】
注意:在試驗之前,請先檢測selinux是否關閉,否則可能會試驗不成功。關於如何關閉selinux請查看第十五章 linux系統日常管理的「linux的防火牆」部分

1. 共享一個目錄,任何人都可以訪問,即不用輸入密碼即可訪問,要求只讀。
打開samba的配置文件/etc/samba/smb.conf
[global]部分
把」MY GROUP」改成」WORKGROUP」
把」security = user」 修改為「security = share」
然後在文件的最末尾處加入以下內容:
[share]
comment = share all
path = /tmp/samba
browseable = yes
public = yes
writable = no

mkdir /tmp/samba
chmod 777 /tmp/samba
啟動samba服務
/etc/init.d/smb start

測試:
首先測試你配置的smb.conf是否正確,用下面的命令
testparm
如果沒有錯誤,則在你的windows機器上的瀏覽器中輸入file://IP/share 看是否能訪問

2. 共享一個目錄,使用用戶名和密碼登錄後才可以訪問,要求可以讀寫
打開samba的配置文件/etc/samba/smb.conf
[global] 部分內容如下:
[global]
workgroup = WORKGROUP
server string = Samba Server Version %v
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw

然後加入以下內容:
[myshare]
comment = share for users
path = /samba
browseable = yes
writable = yes
public = no

保存配置文件,創建目錄:
mkdir /samba
chmod 777 /samba
然後添加用戶。因為在[globa]中」 passdb backend = tdbsam」,所以要使用」 pdbedit」 來增加用戶,注意添加的用戶必須在系統中存在。
useradd user1 user2
pdbedit -a user1 # 添加user1賬號,並定義其密碼
pdbedit -a user2
pdbedit -L # 列出所有的賬號
測試:
打開IE瀏覽器輸入file://IP/myshare/ 然後輸入用戶名和密碼

3. 使用linux訪問samba伺服器
Samba服務在linux下同樣可以訪問。前提是你的linux安裝了samba-client軟體包。安裝完後就可以使用smbclient命令了。
smbclient //IP/共享名 -U 用戶名
如:[root@localhost]# smbclient //10.0.4.67/myshare/ -U user1
Password:
Domain=[LOCALHOST] OS=[Unix] Server=[Samba 3.0.33-3.29.el5_6.2]
smb: \>
出現如上所示的界面。可以打一個」?」列出所有可以使用的命令。常用的有cd, ls, rm, pwd, tar, mkdir, chown, get, put等等,使用help + 命令可以列印該命令如何使用,其中get是下載,put是上傳
另外的方式就是通過mount掛載了:
如:
mount -t cifs //10.0.4.67/myshare /mnt -o username=user1,password=123456
格式就是這樣,要指定-t cifs //IP/共享名本地掛載點 -o後面跟username 和 password
掛載完後就可以像使用本地的目錄一樣使用共享的目錄了。

⑨ Linux下如何搭建SAMBA伺服器

1、相關的文件
samba-common samba伺服器的主文件
samba 伺服器端的軟體
samba-client 客戶端的軟體
redhat-config-samba 圖形界面的配置文件
samba-swat web配置工具
2、步驟
1)安裝SAMBA伺服器
(1)檢測是否安裝samba
#rpm -qa | grep samba
(2)安裝:將第一張光碟放入光碟機
#mount /mnt/cdrom
#cd /mnt/cdrom/RedHat/RPMS
#ls samba*.*
#rpm -ivh samba-common-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-client-2.2.7a-7.9.0.i386.rpm
#cd /
#umount /mnt/cdrom
#eject
2)設置samba的密碼文件
(1)成批用戶密碼文件的生成
#cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
(2)刪除一些無用的shell帳戶
#vi /etc/samba/smbpasswd
從1到9。
(3)設置目錄和文件的許可權
#chown root.root /etc/samba/smbpasswd
#chmod 500 /etc/samba
#chmod 600 /etc/samba/smbpasswd
#ll -d /etc/samba
(4)單個用戶設置samba密碼
#useradd wujianan
#passwd wujianan
#smbpasswd -a wujianan
3)啟動samba伺服器
#service smb start
#pstree | grep mbd
#smbclient -L localhost或者IP地址
4)配置samba的共享
#vi /etc/samba/smb.conf
[global]
workgroup = workgroup
server string = samba server
;hosts allow = 192.168.1. 192.168.2. 127.
printcap = /etc/printcap
load prints = yes
printing = cups
;guest account = pcguest
log file = /var/log/samba/%m.log
max log size = 0
安全選項
security = user(share)
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
;interfaces = 192.168.12.2/24 192.168.13.2/24
dns proxy = no
設置每個用戶主目錄共享
[homes]
comment = Home Directries
browseable = no 不允許瀏覽共享文件夾
writeable = yes 允許寫入
valid users = %s
create mode = 0664
directry mode = 0775
[printers]
comment = All prints
path = /var/spool/samba
browseable = no
printable = yes
[doc]
comment = doc
path = /home/doc
browseable = no
writeable = no或 read only = yes
guest ok = yes
示例:
要求:創建一個共享目錄,所有用戶都可訪問,許可權為只讀。
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = samba server
netbios name = RH9
dos charset = cp936
unix charset = cp936
secrity = share
[read]
comment = read
path = /home/read
public = yes
guest ok = yes
read only = yes
保存退出
#mkdir /home/read
#service iptables stop
#service smb start
#testparm
\\ip地址
創建一個可寫的目錄,允許所有用戶可寫入。
[write]
comment = write
path = /home/write
public = yes
guest ok = yes
writeable = yes
保存退出
#mkdir /home/write
#chmod 777 /home/write
#service iptables stop
#service smb restart
為指定的用戶和組訪問samba伺服器
#useradd mehost
#passwd wujianan
#smbpasswd -a wujianan
#mkdir /var/samba/wujianan
#chown stu1.stu1 /var/samba/wujianan
#vi /etc/samba/smb.conf

security = user

[wujianan]
comment = wujianan
path = /var/samba/wujianan
valid users = wujianan
public = yes
writeable = yes
保存退出
#service smb restart
最簡單的電影伺服器的配置
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = movies server
guest account = nobody
security = share
client code page = cp936
wins support = yes
[movies]
comment = movies
browseable = yes
writeable = no
path = /movies
guest ok = yes
read only = yes
保存退出
#mkdir /movies
#useradd admin -d movies
#passwd admin
#vi /etc/passwd
admin:x:0:500::/movies:/bin/bash
保存退出
#ntsysv
選擇smb和vsftp項
#service smb start
#service vsftpd start
#service iptables stop

熱點內容
java的基本結構 發布:2024-10-11 15:12:24 瀏覽:730
大眾suv哪個內部配置好 發布:2024-10-11 14:30:39 瀏覽:93
緩存到資料庫失敗 發布:2024-10-11 14:27:44 瀏覽:678
我的世界手機國際怎麼創建伺服器 發布:2024-10-11 13:45:46 瀏覽:420
svnlinux命令 發布:2024-10-11 13:35:54 瀏覽:234
ig加密語音 發布:2024-10-11 12:19:25 瀏覽:487
釘圖上傳 發布:2024-10-11 12:11:27 瀏覽:479
腳本個 發布:2024-10-11 12:10:43 瀏覽:151
剛性攻絲的編程 發布:2024-10-11 12:10:39 瀏覽:469
怎麼登錄安卓版全民tv 發布:2024-10-11 12:10:33 瀏覽:624