|
![]() | 作者: authen [authen]
![]() |
登录 |
一、概述 samba采用c/s架构,samba服务器+samba客户端。 认证方式: 使用smbpasswd验证用户口令。 二、取得 方法1: FreeBSD安装光盘 /packages/net/samba-x.x.x.tgz 方法2:ftp://ftp.freebsd.org/pub/FreeBSD/packages/net/samba-x.x.x.tgz 方法3:在线ports 或pkg_add �Cr samba-x.x.x.tgz 方法4: 从www.samba.org下载源代码,编译安装 三、安装和配置 (假定samba-2.2.8a.tgz在 /test目录下) # cd /test # pkg_add samba-2.2.8a.tgz 安装后,配置 # pkg_info �CL samba-2.2.8a.tgz (查看samba-2.2.8a.tgz安装路径) # cd /usr/local/etc # cp smb.conf.default smb.conf # ee smb.conf 四、smb.conf.default #======================= Global Settings ===================================== [global] #全局设置 # workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4 workgroup = MYGROUP #设定工作组,以windows的工作组名称来设定 # server string is the equivalent of the NT Description field server string = Samba Server #服务器描述,可在客户端访问网上邻居时显示为备注 # netbios name = bsd #服务器名为bsd ![]() 补充:可以使用samba设定的变量。这里说一下samba定义的变量: %S = 当前服务名(如果有的话) %P = 当前服务的根目录(如果有的话) %u = 当前服务的用户名(如果有的话) %g = 当前用户说在的主工作组 %U = 当前对话的用户名 %G = 当前对话的用户的主工作组 %H = 当前服务的用户的Home目录 %v = Samba服务的版本号。 %h = 运行Samba服务机器的主机名 %m = 客户机的NETBIOS名称 %L = 服务器的NETBIOS名称 %M = 客户机的主机名 %N = NIS服务器名 %p = NIS服务的Home目录 %R = 说采用的协议等级(值可以是CORE, COREPLUS, LANMAN1, LANMAN2,NT1) %d = 当前服务进程的ID %a = 客户机的结构(只能识别几项:Samba,WfWg,WinNT,Win95) %I = 客户机的IP %T = 当前日期和时间 # 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. #允许访问samba服务器的ip段 ; hosts allow = @staff,authen #允许@staff组用户和authen用户访问samba服务器 ; hosts deny = 192.168.1. 192.168.2. 127. #拒绝访问samba服务器的ip段 ; hosts deny = @staff,authen #拒绝@staff组用户和authen用户访问samba服务器 # If you want to automatically load your printer list rather # than setting them up individually then you'll need this load printers = yes #打印机的设置 # you may wish to override the location of the printcap file ; printcap name = /etc/printcap #打印机的设置 # on SystemV system setting printcap name to lpstat should allow # you to automatically obtain a printer list from the SystemV spool # system ; printcap name = lpstat #打印机的设置 # It should not be necessary to specify the print system type unless # it is non-standard. Currently supported print systems include: # bsd, sysv, plp, lprng, aix, hpux, qnx ; printing = bsd #打印机的设置 # Uncomment this if you want a guest account, you must add this to /etc/passwd # otherwise the user "nobody" is used ; guest account = pcguest #客户端通过这个账号访问samba服务,该账号需要在BSD中添加;如果注释该行或该账号在系统中不存在,则默认使用nobody账号访问samba服务器,建议不要使用nobody账号(因为很多服务都使用nobody,可能会有安全性问题) # this tells Samba to use a separate log file for each machine # that connects log file = /var/log/log.%m #定义samba的日志文件为/var/log目录下的以log为前缀的文件,%m用于代表从访问的NetBIOS 计算机名,如果使用的用户级认证,还可以使用%U表示不同的登录用户。例如从一台名字为win95c的计算机访问samba服务器的日志,将记录在/var/log/log.win95c文件中。 # Put a capping on the size of the log files (in Kb). max log size = 50 #每个日志文件的存储限制。 # Security mode. Most people will want user level security. See # security_level.txt for details. security = user #用户级认证方式。用samba口令(来自/usr/local/etc/smbpasswd )对用户进行认证。 # 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> #设定WINNT域控制器名称,仅当使用security = server时有效。 # Note: Do NOT use the now deprecated option of "domain controller" # This option is no longer implemented. # 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 #口令加密传输 # 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 = /usr/local/etc/smb.conf.%m #系统管理员可以为每个特定的计算机定制一个特定的配置文件,那里的设置将覆盖smb.conf中的缺省设置。这样就可以针对不同的计算机提供不同的配置。如:设定/usr/local/etc/smb.conf.win95c,当win95c访问samba服务器时使用自己的配置文件。可实现对来自不同客户端机器的不同访问策略。 # Most people will find that this option gives better performance. # See speed.txt and the manual pages for details # You may want to add the following on a Linux system: # SO_RCVBUF=8192 SO_SNDBUF=8192 socket options = TCP_NODELAY # socket参数用于配置对TCP的处理方式,以适合Microsoft客户的特征。Microsoft习惯为每个很短的会话都建立单独的连接,而不是使用一个连接进行多次传输,这样在传输中就需要进行多次连接会话设定过程,对性能有一定影响。为了改善性能,需要设置TCP_NODELAY或IPTOS_LOWDELAY选项。 # 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 #网络界面设定,当内网网卡绑定多个网段ip时可指定提供samba服务的网络界面。可结合”;hosts allow = 192.168.1. 192.168.2. 127.”设定不同ip段的访问策略。 # 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 #使得nmdb能对外表现为一个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 = w.x.y.z #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 #是否成为wins代理 # 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 #是否成为dns代理 # Client codepage settings # for Greek users ; client code page=737 # for European users (Latin 1) ; client code page=850 # for European users (Latin 2) ; client code page=852 # for Icelandic users ; client code page=861 # for Cyrillic users ; client code page=866 # for Japanese Users ; client code page=932 ; coding system=cap # for Simplified Chinese Users #简体中文支持 ; client code page=936 ; coding system=cap # for Korean Users ; client code page=949 ; coding system=cap # for Traditional Chinese Users ; client code page=950 ; coding system=cap #============================ Share Definitions ============================== [homes] comment = Home Directories browseable = no writeable = yes #[homes]部分使得每个Unix用户通过SMB客户登录上来的时候,可以共享使用他自己的个人目录。这个共享资源具备特别属性,当用户登录上之后,共享名就不是homes,而是被服务器映射为用户自己的标识符。 设置这个特别的共享选项,就允许每个用户访问自己的个人目录,而不必为每个用户都配置一个共享资源部分。正由于系统会自动映射,因此就不需要定义要共享的文件目录路径,而在其它文件资源共享选项中,都需要使用path参数进行定义。 由于Samba系统会自动将homes共享名改变为用户的个人标识符,因此要设定browseable=no ,设置homes本身这个名字不出现在资源列表中。writable为用户写权限设置,由于是在用户的个人目录下,用户可以具备写权限。 # Un-comment the following two lines to add a recycle bin facility to a samba share # NOTE: It currently doesn't work with the [homes] virtual share, use a regular share instead ; vfs object = /usr/local/lib/samba/recycle.so ; vfs options= /usr/local/etc/recycle.conf.default # 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 ; writeable = no ; share modes = no #当允许Samba服务器支持客户的网络登录功能之后(设置domain logon),就需要设置[netlogon] 部分(删除注释符号),为guest用户打开登录路径的访问权限,以保证每个用户都能访问其自己的登录脚本。由于需要使用guest对应的Unix帐户访问登录脚本,这个登录路径及其下面的脚本文件都要允许该Unix帐号可以读取。 建立这个目录之后,要设定正确的权限,并且创建这个目录下对应各个计算机或用户的登录脚本,以提供给客户正确的登录脚本。 # 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 #当支持Windows计算机漫游能力时,可以设定[Profiles]部分,并为相应的路径建立目录,及分配权限。来为Window计算机用户设置桌面环境。 # NOTE: If you have a BSD-style print system there is no need to # specifically define each individual printer [printers] #打印机设置 comment = All Printers path = /var/spool/samba browseable = no # Set public = yes to allow user 'guest account' to print guest ok = no writeable = no printable = yes # This one is useful for people to share files #共享目录设置 ;[tmp] ; comment = Temporary file space #标题 ; path = /tmp #路径 ; allow hosts = host(subnet) #允许的主机 ; deny hosts = host(subnet) #拒绝的主机 ; writable = yes|no #是否可写,最终以目录权限为准 ; valid users = user(@group) #可登录用户或组 ; invalid users = user(@group) #不可登录用户或组 ; browseable = yes|no #是否可被浏览到 ; read list = user(@group) #可read用户或组 ; write list = user(@group) #可写入的用户或组 ; read only = yes|no #是否只读 ; admin list = user(@group) # ; public = yes|no #等同于guest ok = yes 该资源能否匿名访问 ; hide dot files = yes|no # ; create mode = 0755 #指明新建立的文件的属性 ; directory mode = 0755 #指明新建立的目录的属性 ; sync always = yes|no #指明对该共享资源进行写操作后是否进行同步操作。 ; short preserve case = yes|no #指明是否管文件名大小写。 ; preserve case = yes|no #指明保持大小写。 ; case sensitive = yes|no #指明是否对大小写敏感,一般选no,不然可能引起错误。 ; mangle case = yes|no #指明混合大小写。 ; default case = upper|lower #指明缺省的文件名是全部大写还是小写。 ; force user = authen #强制把建立文件的属主是谁。 ; wide links = yes|no #指明是否允许共享外符号连接,比如共享资源里面有个连 #接指向非共享资源里面的文件或者目录,如果设置wide #links = no将使该连接不可用。 ; max connections = 100 #设定同时连接数 ; delete readonly = yes|no #指明能否删除共享资源里面已经被定义为只读的文件。 光驱的共享: [cdrom] ; comment = grind’s cdrom ; path = /mnt/cdrom ; public = yes ; browseable = yes ; root preexec = /bin/mount -t iso9660 /dev/cd0 /mnt/cdrom ; root postexec = /bin/umount /mnt/cdrom #root preexec指明了连接时用root的身份运行mount命令,而root postexec则指明了断开时用root #身份运行umount,有效实现了对光驱的共享。 打印机共享的设置: [printers] path = /var/spool/samba writeable = no guest ok = yes printable = yes printer driver = HP LaserJet 5L 这里printable指明该打印机可以打印, guest ok说明游客也能打印,path指明打印的文件队列暂时放到/var/spool/samba目录下。printer driver的作用是指明该打印机的类型,这样我们在安装网络打印机的时候可以直接自动安装驱动而不必选择。 [global]用于设定全局参数,不会出现在资源列表中,[homes]用于设定个人目录共享,其共享的名字映射为个人标识符而非homes,[printers]设定打印机共享,将共享所有的打印机名字,除了这些标题的共享名字与标题不同之外,其他每个标题都将代表一个共享资源的名字。 当更改设置之后,可以重新启动Samba服务器,提供新的共享服务了。但在重新启动服务器之前,最好使用 Samba软件包中提供的测试软件,检查一下设置是否正确。这些小工具程序包括检查smb.conf设置的testparm ,检查打印机名字的正确性的程序testprn,用于进行NetBIOS名字解析的nmblookup等。 四、启动samba服务器 方法1:[命令行方式1] #/usr/local/sbin/nmbd -D # usr/local/sbin/smbd -D (手动启动) 方法2: [命令行方式2] #ee smbstart 引用: # chmod +x smbstart [就是做一脚本文件而已 呵呵] 方法3: [inetd方式] 确保以下两行在/etc/services中 netbios-ssn 139/tcp netbios-ns 137/udp 在/etc/inetd.conf中加入 netbios-ssn stream tcp nowait root /usr/local/sbin/smbd smbd netbios-ns dgram udp wait root /usr/local/sbin/nmbd nmbd 此方式在用户数量较多时对系统资源占用较大。 方法4: [后台启动方式] 加入/etc/rc.local 五、远程管理 方法1:telnet或ssh上去后配置/usr/local/etc/smb.conf 然后重启smbd 方法2:使用swat 1. 确保 /etc/services中有 swat 901/tcp 这行 2. 在etc/inetd.conf中加入: 引用: 3.重启系统或 引用: 4.客户端可在浏览器中输入: http://ip:901 然后输入BSD系统root用户名+口令进入配置页面。 六、添加用户口令: #smbpasswd -a username 该账户需在/etc/passwd中存在 #smbpasswd -d username 停用账户 #smbpasswd -e username 启用账户 七、客户端配置 windows客户端登录用户名、口令必须与samba验证用户名、口令一致 八、我的实例 [未经单位同意,不能公布 ![]() |
地主 发表时间: 05-01-04 11:00 |
![]() | 回复: teczm [teczm] ![]() |
登录 |
那是采用win域认证时用的,我没试验过,所以不知道。 |
B1层 发表时间: 05-01-05 08:51 |
![]() | 回复: cimsxiyang [cimsxiyang] ![]() |
登录 |
不错:) 不知道的部分看注释 继续..... [此贴被 夕阳(cimsxiyang) 在 01月07日09时39分 编辑过] |
B2层 发表时间: 05-01-07 09:36 |
![]() | 回复: Nebulae [xingyun] ![]() |
登录 |
好复杂 看不懂 |
B3层 发表时间: 05-01-08 10:02 |
![]() | 回复: TecZm [teczm] ![]() |
登录 |
权威手册 http://us1.samba.org/samba/docs/using_samba/toc.html |
B4层 发表时间: 05-01-11 11:19 |
![]() | 回复: afan271314 [afan271314] ![]() |
登录 |
我的的 linux 是虚拟机 启动SMB应该在网上邻居里看到默认的MYGROUP组 为什么有是能有不能配置都一样 有经验的大哥能不能给说一下 应注意什么 |
B5层 发表时间: 05-01-12 18:03 |
![]() | 回复: TecZm [teczm] ![]() |
登录 |
引用: 这句看不懂 |
B6层 发表时间: 05-01-12 18:19 |
![]() | 回复: shengkou [shengkou] ![]() |
登录 |
正好在安装配置samba 不过我freebsd5.3装的samba3.0.10 无法启动,晕哦,等些 把/usr/local/etc/rc.d/samba.sh贴出来看看 不知道为啥启动不来 |
B7层 发表时间: 05-01-21 14:38 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号