成功配置Samba3.0为域登录和文件服务器的方法﹗﹗﹗

来源:互联网 发布:苏联足球知乎 编辑:程序博客网 时间:2024/05/07 12:33
 
Samba3.0也已经出来了﹐我也是个Linux爱好者﹐最近手痒﹐也下载下来配置一下﹐感觉还不错﹐与大家一起分享﹐错误之处还望指正  

我的系统是Red Hat9.0安装的时候我没有选择Linux作为文件服务器﹐那是因为我想在系统安装完毕之后再安装Samba,这样会省去一点麻烦 ﹐大家也可以升级安装samba3.0rpm包。 
方法如下: 
#rpm -Uvh --force --nodeps samba-common-3.0.0.15.i386.rpm 
#rpm -Uvh --force --nodeps samba-client-3.0.0-15.i386.rpm 
#rpm -Uvh --force --nodeps samba-3.0.0-15.i386.rpm 
此外还有一个工具就是图形界面的Swat。 
要是用这个工具﹐大家还要修改一处﹐就是﹕ 
vi /etc/xinetd.d/swat把其中的 
disable = yes 
改为 
disable = no就可以了。 
#rpm -ivh samba-swat-3.0.0-15.i386.rpm 
然后开启浏览器输入http://hostname:901. 
也可以安装redhat-config-samba这个工具﹐不过我不是很喜欢它﹐不实用。 
为了方便远程管理﹐Webmin也不错﹐现在已经是1.121的版本了﹐建议大家装上它﹐通过它大家就能轻易地配置好Samba. 
这里我不介绍通过webmin来架设samba服务器﹐还是按照我的配置文件叙述开来﹐方便﹐嘿嘿﹗﹗﹗ 
下面是我的/etc/samba中的smb.conf文件的内容﹕ 
# Samba config file created using SWAT 
# from 0.0.0.0 (0.0.0.0) 
# Date: 2003/11/19 15:38:38 

# Global parameters 
#全局配置参数 
[global] 
#设置工作组或者说是域名。 
workgroup = MYGROUP 
#网络上看到的计算器名称(samba)。 
netbios name = SAMBA 
#服务器描述﹐%v显示Samba版本。 
server string = Samba Server %v 
#设置samba服务器使用的认证过程。默认为USER﹐有四个选项﹕User,Share,Server和Domain. 
Security = User 
#设置纯文本密码的最少字符数。 
min passwd length = 6 
#匿名﹑名称﹑密码都不正确不准登录服务器。即任何非法用户名登录均被视为gues用户。 
map to guest = Bad User 
#用户名的映像。 
username map = /etc/samba/smbusers 
#存放samba密码的路径 
smb passed file = /etc/samba/smbpasswd 
#samba日志文件的名字和路径。 
log file = /var/log/samba/%m.log 
#日志文件的最大尺寸(KB) 
max log size = 50 
#作为时间服务器。 
time server = Yes 
#设置连接被视为无效而断开前﹐未激活状态的时间(MIN)﹐防止资源被无效连接耗费。 
deadtime = 5 
#网络协议选项﹐注意不要更改﹐否则影响网络速度及网络问题。 
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 
#用户成功登录时在netlogon共享中运行的批处理文件或者windows命令文件﹐注意﹕这一项很重要﹐还有就是一定要配合下面的[netlogon]共享才能配置出你的PDC﹐%U为自动匹配登录用户的名称。 
logon script = %U.bat 
#在服务器上保存Windows用户登录时的配置文件路径﹐%L为Samba匹配服务器名称。 
logon path = //%L/profile/%U 
#设定登录时主目录的当地路径。 
logon drive = H: 
#Samba接受所在组用户以域登录。 
domain logons = Yes 
#如果要把samba设置为域服务器﹐浏览器的OS级别一定要高于Windows。这里说名一下﹕OS级别﹕windows95为1﹐98为16﹐2000为32. 
os level = 65 
#设置samba试图成为主浏览器。 
domain master = Yes 
#设置samba为WINS服务器。 
wins support = Yes 
#超级用户。 
admin users = root 
#设置新文件权限。 
create mask = 0740 
#建立新文件时强制权限限制。 
force create mode = 0740 
#允许用户在NT/2000下改变权限。 
security mask = 0740 
force security mode = 0740 
#创建新目录时允许拥有的最大权限。 
directory mask = 0750 
force directory mode = 0750 
directory security mask = 0750 
force directory security mode = 0750 
#Windows工作方式﹐只要文件被修改﹐其时间戳将随时更新。 
dos filetimes = Yes 
#Samba对文件生成时间作取整处理﹐计为下1秒﹐这也是windows工作方式。 
dos filetime resolution = Yes 
#共享家目录。 
[homes] 
comment = Home Directories 
read only = No 
browseable = No 
#重要的设置﹐samba作为域服务器时存放用户登录时执行的文件或脚本。 
[netlogon] 
comment = Network Logon Service 
path = /home/netlogon 
write list = root 
guest ok = Yes 
share modes = No 
#用户配置文件存放目录 。 
[Profile] 
path = /home/profiles 
read only = No 
create mask = 0770 
force create mode = 0770 
security mask = 0770 
force security mode = 0770 
directory mask = 0770 
force directory mode = 0770 
directory security mask = 0770 
force directory security mode = 0770 
browseable = No 
#打印机共享目录。 
[printers] 
comment = All Printers 
path = /var/spool/samba 
printable = Yes 
browseable = No

发表回复】【查看论坛原帖】【添加到收藏夹】【关闭

 zhaosi 回复于:2003-11-19 18:31:47
注释很清楚,不错,只是繁体看起来不方便。


 feiwupiaoxue 回复于:2003-11-19 20:11:57
好﹐Smb.conf文件配置完成。接下来就要手动在/home下建立目录﹕ 
profiles,访问权限为0770,组为你想要建立的组﹐比如share. 
用来存放Windows用户的配置文件。 
netlogon访问权限为1750﹐这里加上了sticky选项﹐不允许其它用户删除目录里的文件﹐只有超级用户或者建立者才可以﹐注意sticky选项只对目录起作用。组为share。 
下面建立/etc/samba下面的smbpasswd文件﹕ 
# cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd 
为了安全起见﹐设置权限﹕ 
#cd /etc 
#chmod 500 samba 
#cd samba 
#chmod 600 smbapsswd 

接下来大家可以在netlogon目录里建立windows用户的登录脚本﹐比如批处理文件﹐需要注意的是﹐一定要在Windows下面建立﹐因为如果在Linux下建立﹐那幺Windows就不会执行Linux的文件。比如有个帐户feixue,批处理文件可以这样﹕ 
feixue.bat内容为﹕ 
@net time //SambaServer /set /yes 
@net use H: //SambaServer/feixue -y 
@regedit -s //SambaServer/netlogon/*.reg 
等。 

需要注意的是把批处理文件保存到netlogon下面后一定要检查文件的权限﹐修正后用户才会执行﹐不然的话嘿嘿﹐你有麻烦了﹗﹗﹗ 

如何配置Windows端登录Samba域﹐对于98来说﹐很容易﹐在网络属性里选 Client for microsoft networks﹐在第一项打勾﹐下面输入你的Samba服务器的域名(工作组).重新激活机器以后﹐邓入对话框就会有三项﹕用户名﹑密码﹑域名。 
NT/2000下面登录samba域会困难一点﹐首先你要在Samba服务器上建立windowsNT/2000机器的信用帐号。 
下面以一个计算器名为test的计算机为例﹕ 
#useradd -c 'Test Compter' -d /dev/null -g share -s /bin/false -r test$ 
我们创建了一个Linux本地帐号﹐出于安全的考虑不需要它登录到Linux进行任何操作﹐因此的用户目录为/dev/null,shell是/bin/false. 
然后我们就可以用smbpasswd创建相应的Samba机器帐号﹕ 
#smbpasswd -a -m test 
其中-a是添加﹐-m是机器信任帐号。这样﹐依据test$的Linux帐号创建了一个NT域的机器信任帐号test. 
然后在windowsNT/2000上加入Samba域﹐根据提示输入超级用户的用户名称和密码﹐就可以加入Samba域了。 
重新激活机器以后﹐就会有三个选项了﹐比如用原先建立的用户feixue邓入即可。 

好了﹐到此为止﹗ 

有时间我再加上Samba打印共享的方法  

祝你好运﹗﹗﹗ 
有什幺问题大家可以和我一快儿交流交流 :lol:


 feiwupiaoxue 回复于:2003-11-19 21:34:38
好了﹐现在看起来怎幺样﹐不好意思﹐因为我的系统是繁体的﹐现在我把文章改为简体了﹐满意了吧﹐呵呵﹗﹗﹗ :lol:


 simplelove 回复于:2003-11-19 22:47:30
非常满意,呵呵

感谢 feiwupiaoxue


 yama998 回复于:2003-11-19 23:06:18
很好,收下了,謝謝Feiwupiaoxue,置頂!!!!!


 robert2000 回复于:2003-11-20 09:40:59
不錯呀!但是我設有samba  密碼卻不用輸入用戶和密碼就都可以進,有沒有辦法解決呀?多謝!


 daisy_chi 回复于:2003-11-20 09:50:00
支持一下


 好好先生 回复于:2003-11-20 10:26:31
[quote:22edfc4a26="robert2000"]不錯呀!但是我設有samba  密碼卻不用輸入用戶和密碼就都可以進,有沒有辦法解決呀?多謝![/quote:22edfc4a26]
vi /etc/samba/smb.conf
/security
修改为security=user
servce smb restart一下。
看看结果


 cgweb 回复于:2003-11-20 10:29:24
feiwupiaoxue,谢谢,写的好呀!


 webfox 回复于:2003-11-20 14:52:07
这个我都试过可以成功,但在windowsxp或者win2003下登陆就不可以,不知道为什么?楼主有什么办法可以解决吗?听说xp以上版本的windows的域和以前有点不同。


 feiwupiaoxue 回复于:2003-11-20 23:18:15
很不好意思,在2003和XP下面我沒有試過,有時間一定解決這個問題,我想應該是差不多吧,呵呵!!!


 原著精華 回复于:2003-11-20 23:25:24
十分感謝!!!


 llzqq 回复于:2003-11-21 00:10:47
PIC







 apile 回复于:2003-11-21 08:16:31
請問一下,你怎麼處理中文字問題????
我先前用tarball安裝過..但是碰到中文字就完了...
原本我有個samba server 2.2 可以設置cp950的codepage..
但是裝上samba 3.0後,原本的中文目錄全部變成亂碼..
但是新建立的目錄,還是看得到中文...
看網上的一堆文章...說得都是unicode與big5的問題...
 CP437.so
 CP850.so
他的samba/lib/charset中只有這兩個 codepage...
不知道有沒有那位老大...知道怎麼加入
其他的CPXXX.so...????
所以後來不得以我還是用samba 2.2版本...


 tiansgx 回复于:2003-11-21 09:37:11
继续关注ing


 llzqq 回复于:2003-11-21 10:38:46
MY SMB.CONF

#======================= Global Settings =====================================
[global]

# workgroup = NT-Domain-Name or Workgroup-Name
   workgroup = redhat
   netbios name = home
# server string is the equivalent of the NT Description field
   server string = Samba Server %v

# 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.0.0/255.255.255.0

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

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

# 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 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*UNIX*password* %n/n *ReType*new*UNIX*password* %n/n 

*passwd:*all*authentication*tokens*updated*successfully*

# Unix users can map to different SMB User names
username map = /etc/samba/smbusers
map to guest = bad user

# 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

# 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


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

# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
os level = 65

# 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 = scripts%m.bat
# run a specific logon batch file per username
 logon script = scripts%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
 logon drive = H:


# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
 wins support = yes

# 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


admin users = root



#============================ Share Definitions ==============================
[homes]
   comment = Home Directories
   browseable = no
   read only = no
# 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 = /home/netlogon
   guest ok = yes
   write list = root
   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 = /home/profiles
    read only = no
    create mask = 0770
    force create mode = 0770
    security mask = 0770
    force security mode = 0770
    directory mask = 0770
    force directory mode = 0770
    browseable = no


 llzqq 回复于:2003-11-21 10:40:43
谁碰到了和我一样的问题,还请多多交流!!


 webfox 回复于:2003-11-21 12:00:44
llzqq
你试试加入
add user script = /usr/sbin/useradd -d /dev/null -g 100 -s /bin/false -M%u
有谁知道xp和win2003为什么不能域登陆到samba吗?


 carrison 回复于:2003-11-21 12:28:27
好文!


 llzqq 回复于:2003-11-21 17:53:14
经过不歇的努力终于成功了


 ahakka 回复于:2003-11-21 18:18:34
[quote:5e37357cf0="webfox"]llzqq
你试试加入
add user script = /usr/sbin/useradd -d /dev/null -g 100 -s /bin/false -M%u
有谁知道xp和win2003为什么不能域登陆到samba吗?[/quote:5e37357cf0]

请将这个文件在XP或2003下执行一下:

/usr/share/doc/samba-3.0.0/docs/Registry/WinXP_SignOrSeal.reg

我曾经在SAMBA-2.8.0下面,让WINXP登录SAMBA域,就用上面的补丁,成功通过。我想SAMBA-3.0也应该是这个问题。大家可以试。。。。

顺便说一下,这篇文章真不错!


 qdreal 回复于:2003-11-23 13:28:44
good , perfect!


 llzqq 回复于:2003-11-23 14:50:26
我发现客户端用户不能修改他们的登陆密码,有人能解决吗?


 robert2000 回复于:2003-11-24 18:02:51
好好先生說:
vi /etc/samba/smb.conf 
/security 
修改为security=user 
servce smb restart一下。 
看看结果 

都有修改的,但是不用密還可以進,真不明呀!還有沒有其它原因呢?多謝!


 llzqq 回复于:2003-11-24 18:50:50
你的客户机上是否有和LINUX上相同帐户和密码


 robert2000 回复于:2003-11-26 11:05:41
沒有呀,都是不同的,,


 panwj 回复于:2003-11-26 11:56:51
必须是ADMIN用户才能把计算机加入SAMBA域


 feiwupiaoxue 回复于:2003-11-28 10:43:03
大家可以把从网上当下来的注册表的文件倒入注册表中就可以了,nt/2000登入到域中去一定要用到超级用户的名称和密码(root,***),还有字符集samba使用的是utf-8,并没有象原来的那样
使用:
client code page = 950或者936之类的呵呵!!!


 llzqq 回复于:2003-11-28 14:40:31
普通用户不能修改自己的密码(按Ctrl+Alt+Del键)


 robert2000 回复于:2003-12-01 16:31:30
oh


 xueada 回复于:2003-12-01 17:18:40
关于samba3的中文问题,试试在smb.conf 全局区加:display charset = cp936,我机器(fedora+samba3)上是这么解决的

在/usr/share/samba/codepages里有关于cp936的页文件,只不过samba3的配置文件中关于character的关键字变了


 eagerlinuxer 回复于:2003-12-01 22:21:09
写得真是很好,我想问楼主一个也许于此无关的问题:如何把一台linux的samba服务器加入到一个WIN2000域中,做一个WIN2000域中的文件服务器呢?有什么办法?


 garycn 回复于:2003-12-17 16:53:36
我想知道.bat文件用什么生成,有哪些规则呢?谢谢大家!


 woodsbill 回复于:2004-02-03 16:53:17
samba3.0.1,windows域用户通过机器名访问samba服务器,无法通过验证,通过ip地址访问可以通过验证,本地用户可以通过域名访问,是什么原因?