gugong 发表于 2002-11-18 11:03:15

Samba 速成,更深入在以后讨论

先看看我的 smb.conf 文件:

# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
# /etc/samba/smb.conf 文件
#
#======================= Global Settings =====================================


   workgroup = linux

   create mask = 0755
   directory mask = 0755

#由于 SAMBA 是一位欧洲人编写的,client code page 的缺省值是        850 (西欧)。
#我们需要把它改成 936 (中文简体)。                                {437 (USA)}
   client code page = 936
   dos charset = cp936
   unix charset = cp936

#guest 用户映射仅适用于安全模式(user,server和domain安全级)。
#如果一个用户没有通过身份验证,就可以将其映射为guest用户。从而允许
#他访问 guest 共享。这里 guest 用户由 guest account= 参数指定。
   map to guest = Bad User
   map to guest = Bad Password
   guest account = nobody

# ------- 同 windows 机器 的 winpopup 聊天---------
#
#为了处理 WinPopup 信息, Samba 提供了 "message command"全局参数,它定义
#了信息到来时 Samba 应采取的措施. 例如:
;
;message command = /bin/mail -s 'message from %f on %m' root < %s; rm %s &
;
#注意:该命令必须立即返回,因此其后应该加上符号"&".
;message command = /usr/X11R6/bin/gvim %s ;   rm -f %s &      == NO SUCCESS ==
;message command = /usr/bin/gxedit %s ;       rm -f %s &      == NO SUCCESS ==
;message command = /usr/bin/kwrite %s ;       rm -f %s &
;message command = /usr/bin/gless %s ;      rm -f %s &      == NO SUCCESS ==
;message command = /usr/bin/gnp %s ;          rm -f %s &      == NO SUCCESS ==
;message command = /usr/bin/kedit %s ;      rm -f %s &
;message command = /usr/bin/gedit %s ;      rm -f %s &      == NO SECCUSS ==
;message command = (/usr/bin/gless %s ;       rm -f %s)&
;message command = /usr/bin/gless %s ;      rm -f %s &
;message command = /bin/mail -s 'Message from %f %M on %m %I' root < %s ; rm -f %s &
;message command = /usr/bin/linpopup "%f" "%m" %s; rm %s

   message command = /usr/bin/linpopup "%f" "%m" %s; rm %s
#

#寻找 windows 机器的先后循序:
   name resolve order = host wins bcast lmhosts

   local master = yes

#------------------ 作域登录服务 ------------------
   domain master = yes

   preferred master = yes

   domain logons = yes
#------------------ 作域登录服务 ------------------

# 如果做域登录服务,对于每一台机器或者每一个用户,您可能需要一个登录脚本来运行指定的批处理文件。
# 对于某“机器” 运行登录批处理文件。
;   logon script = %m.bat
# 对于某 “用户” 运行登录批处理文件。
;   logon script = %U.bat

   announce version = 5.0
   announce as = Windows NT Enterprise Edition 5.0

   log file = /var/log/samba/log.%m
   max log size = 0

;interfaces = 192.168.20.8/24 211.148.130.133/28

   deadtime = 5

   hosts allow = 127.0.0. 192.168.20. 192.168.30. 211.148.130.128/255.255.255.240
   hosts deny = all


#只要使用者有权限,即使目录不为空,也可以将它删除.
   delete veto files = True

#使得“Nimba Worm”类病毒写的文件对所有的客户机不可见(*.eml、*.nws、riched20.dll)。
   veto files = /*.eml/*.nws/riched20.dll/*.bat/*.scr/*.pif/
#同样使得“Klez Worm”类病毒写的文件对所有的客户机不可见。
#(注意:*.bat、*.scr、*.pif、*.rar等文件不是完全是病毒写的!)

#将目录“/proc”和“/dev”的内容显示为空。
   dont descend = /proc, /dev

#将时间解析设为2秒,是为了让 Visual C++ 更好地工作(作用于共享的 SMB 文件时)。
   dos filetime resolution = True

#当客户连接到一个服务时,指定运行的命令。
;preexec = csh -c echo \"Welcome to %S!\" | smbclient -M %m -I %I&


   printcap name = /etc/printcap
   load printers = yes
   printing = lprng

   max log size = 0
   security = user

#================ 要使 Samba 使用加密口令,必须加入以下参数: =================
   encrypt passwords = yes
   smb passwd file = /etc/samba/smbpasswd

#======如果允许用户使用空口令,则应该使用如下参数:
;null passwords = yes

   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*

;obey pam restrictions = yes

   socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

#使本机器成为 WINS 服务器。
   wins support = yes

;wins proxy = yes

   dns proxy = no


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

   comment = Home Directories
   browseable = no
   writable = yes
   valid users = %S
   create mode = 0775
   directory mode = 0775
# If you want users samba doesn't recognize to be mapped to a guest user
; map to guest = bad user

[公共文件]
   comment = 公共文件夹
#这个目录是 不需要 是 系统或者说 Samba 的用户 就可以读的。
#其属主为 root 或者别的用户(不是 nobody,处于安全的原因)。
#其目录属性为 755 以上,文件属性为 644 以上。
path = /home/gugong/public
#实际上这个目录是 gugong 来管理。
   browseable = yes
   writable = no
   read only = yes
   guest ok = yes
   create mask = 0666

[临时文件夹]
   comment = 您可以复制您的文件到此目录
#这个目录是 不需要 是 系统或者说 Samba 的用户 就可以写的。
# 其目录属性应为: 1777 。
path = /home/tmp
   browseable = yes
   writable = yes
   read only = no
   guest ok = yes
   create mask = 0666

;[动态网页]
;   comment = Apache + PHP4 + MySQL 动感网页
;   path = /var/www/phtml
;   read only = yes
;   public = yes


   comment = Network Logon Service
   path = /home/netlogon
   guest ok = yes
   writable = no
   share modes = no


# Un-comment the following and create the netlogon directory for Domain Logons
;
;   comment = Network Logon Service
;   path = /usr/local/samba/lib/netlogon
;   guest ok = yes
;   writable = no
;   share modes = no

;[光驱]
;   comment = WWW 光驱
;   path = /mnt/cdrom
;   guest ok = yes
;   browseable = yes


    path = /home/%U/profiles
#                     把用户私人的 profiles 目录放在用户的主目录下。
;
    browseable = no
    guest ok = yes

# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;
;    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 individual printer

   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

gugong 发表于 2002-11-18 11:16:05

然后生成 Samba 的用户 /etc/samba/smbpasswd 。

首先 Samba 的 用户在 Linux 系统里面 必须存在。


若你的系统已经存在了大量的用户,可以
cat /etc/passwd | mksmbpasswd.sh > /etc/smbpasswd
生成 /etc/smbpasswd 文件。这时 其密码还没有设置。需要 smbpasswd user 来设置密码。


或者 使用 smbadduser 命令来生成 smb 的用户:
2002年11月18日上午11时13分53秒# smbadduser
----------------------------------------------------------
Written: Mike Zakharoff email: [email protected]

   1) Updates /etc/samba/smbpasswd
   2) Updates /etc/samba/smbusers
   3) Executes smbpasswd for each new user

smbadduser unixid:ntid unixid:ntid ...

Example: smbadduser zak:zakharoffm johns:smithj
----------------------------------------------------------

会提示你输入密码。



注意:

一、我提供的 smb.conf 文件对于这个文件里面的 “公共文件” 是任何人(这里的意思是 不需要 是 系统或者samba的用户,下同)有 读 的权限,是不必要设置系统用户的; “临时文件夹” 是任何人都可以 写 的,也是不必要设置系统用户的 !


二、任何对 SAMBA 的访问都要通过 Linux 系统本身的权限验证。

我们添加 guest account = nobody 的作用正是如此。




我这是只是提供一个速成的方法。您使用后会慢慢体会、感觉到 SAMBA 服务器的妙处。

就我自己的感觉而言,那真是妙不可言 !!!

Good Luck to You !


kleinblue 发表于 2002-11-18 23:20:59

不错。。。

netdigger 发表于 2002-11-20 16:11:52

好文章!

NULLOF 发表于 2002-11-21 10:03:07

谢谢了。

blackwhite 发表于 2002-11-23 01:08:20

下面的地址有很详细的说明.
http://linuxfocus.org/ChineseGB/May2002/article247.shtml

netdigger 发表于 2002-11-24 08:16:36

我有个问题,当我把security = server改成domian后,所有机器的都不能访问不能访问我了,需要输入密码。怎么回事?还需要做什么动作?

gugong 发表于 2002-11-24 13:14:51

security = server

在 server 安全级下, Samba 使用远程 SMB 服务器(如 Windows NT 服务器)进行身份验证,如果失败则自动切换到 user 安全级.对于客户机来说, server 安全级和 user 安全级没有什么不同.

security = domain
要是用本模式,必须使用 smbpasswd 程序将 Samba 服务器加到一个 Windows NT 域中,并且使用"加密口令(Encrypted Passwords)".在本安全级下, Samba 借助 Windows NT 主控服务器( Windows NT Primary )或者是后备域控制器(Backup Domain Controller) 进行身份验证,采取 Windows NT 服务器相同的行为.


具体见:

http://shcore.com.cn/gugong/gugong/html/samba.phtml

hgkrt 发表于 2002-12-17 13:33:12

好呀,好呀,回去看看..可否在VMWARE中装WIN来实现SAMBA呢??

liushuwen 发表于 2002-12-27 13:17:24

我太菜,看不懂

Fujinsan 发表于 2003-1-2 16:02:25

在VMware里装的RedHat怎么配置才能让本机和其他机器上的Win访问VMware里的Samba?

gugong 发表于 2003-1-2 16:54:00

一样的呀。

好像你的 Linux 机器就是网络上的机器一样地来访问它。

hbliu 发表于 2003-2-10 16:49:21

我太菜,redhat8.0按装完后,怎么就是swas没有运行.

haohaoo 发表于 2003-2-13 17:14:04

swas可以做什么用?

hbliu 发表于 2003-2-14 16:47:17

我的机器出现: 211.103.80.67 sent an invalid ICMP error to a broadcast.
请帮帮忙.
多谢个位!
页: [1] 2 3 4 5
查看完整版本: Samba 速成,更深入在以后讨论