当前位置:首页 » 操作系统 » 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

热点内容
ig加密语音 发布:2024-10-11 12:19:25 浏览:485
钉图上传 发布:2024-10-11 12:11:27 浏览:477
脚本个 发布:2024-10-11 12:10:43 浏览:149
刚性攻丝的编程 发布:2024-10-11 12:10:39 浏览:467
怎么登录安卓版全民tv 发布:2024-10-11 12:10:33 浏览:622
服务器接收的参数名是什么 发布:2024-10-11 12:05:38 浏览:640
c语言中的goto 发布:2024-10-11 11:57:14 浏览:394
小司马编程 发布:2024-10-11 11:45:03 浏览:83
未使用标签进行编译 发布:2024-10-11 11:45:00 浏览:835
java开发源码下载 发布:2024-10-11 11:39:22 浏览:749