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 =====================================
[global]

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 ==============================
[homes]
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

[netlogon]
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
; [netlogon]
; 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

[Profiles]
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
;[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 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
writable = no
printable = yes


然后生成 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秒[root@www html]# smbadduser
----------------------------------------------------------
Written: Mike Zakharoff email:
michael.j.zakharoff@boeing.com

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 !
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值