Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1436285
  • 博文数量: 463
  • 博客积分: 10540
  • 博客等级: 上将
  • 技术积分: 5450
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-12 08:30
文章分类

全部博文(463)

文章存档

2014年(2)

2012年(14)

2011年(42)

2010年(18)

2009年(78)

2008年(35)

2007年(182)

2006年(92)

我的朋友

分类: 系统运维

2006-11-14 17:08:25

Samba 服务详解
 
  samba server 的配置文件在 /etc/samba/ 下的 smb.conf 打开一个终端中输入:gedit /etc/samba/smb.conf 也可以用 vi 编辑.由于文件太长,我把个人认为没有用的东东删除了,主要是一些注释。下面偶解释一下主要字段的意思。由于我的这个文件配置过了,可能你的机器和我的不一样.
  ======================= Global Settings =====================================
  [global] //设置 samba 服务整体环境
  workgroup = hackase //设置工作组名
  server string = angel server //服务器的名说明
  ; hosts allow = 192.168.1. 192.168.2. 127. //限制可访问此服务的 IP 范围,默认是全部允许的,要是想设设置去掉前面的";"
  printcap name = /etc/printcap //打印机配置文件
  load printers = yes //是否共享打印机
  # bsd, sysv, plp, lprng, aix, hpux, qnx, cups
  printing = cups //打印机的类型.标准打印机类型包括以上几种.
  ; guest account = pcguest //pcguest 为用户名.可改去掉前边的 ";" 让用户以 pcguest 身份匿名登录,但保证 /etc/passwd 中有此人。
  log file = /var/log/samba/%m.log //为登录服务器的用户建立不同的日志文件。
  max log size = 0 //日志文件的大小,"0" 代表无限制
  //以下是 smb.conf 文件对服务器安全级别的设置
  security = SHARE //安全性的级别共四种。share、user、server、domain
  ; password server = 密码验证服务器.
  ; password level = 8 //密码级别
  ; username level = 8
  encrypt passwords = yes //用户密码加密,当然也可以不加密
  smb passwd file = /etc/samba/smbpasswd //将密码服务器设置为 samba server。需要这个东东来指定验证文件.这个是文件的路径,如果 samba server 是指定的 win server 这个不须要
  ; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt
  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*
  pam password change = yes
  ; username map = /etc/samba/smbusers //如果每个 windows 用户在 samba 服务器中有帐户这个可以不设
  ; include = /etc/samba/smb.conf.%m
  obey pam restrictions = yes
  ; interfaces = 192.168.12.2/24 192.168.13.2/24 如果多网段要在这里列出
  ; remote announce = 192.168.1.255 192.168.2.44
  ; local master = no
  ; os level = 33
  ; domain master = yes
  ; preferred master = yes
  ; domain logons = yes
  ; logon script = %m.bat
  ; logon script = %U.bat
  ; logon path =
  ; wins support = yes //wins server 支持
  ; wins server = w.x.y.z
  ; wins proxy = yes //wins 代理设置
  dns proxy = no //dns 代理设置
  ; preserve case = no
  ; short preserve case = no
  ; default case = lower
  ; case sensitive = no
  #============================ Share Definitions ==============================
  [homes] //用户访问自已目录的设置
  comment = Home Directories //说明(以下同理)
  browseable = no//设定目录可不可以别人浏览
  writeable = yes//用户写入自己的权限
  valid users = %S
  create mode = 0664
  directory mode = 0775
  ; [netlogon] //此段域用户登录目录设置
  ; comment = Network Logon Service
  ; path = /usr/local/samba/lib/netlogon
  ; guest ok = yes
  ; writable = no
  ; share modes = no
  ;[Profiles]
  ; path = /usr/local/samba/profiles
  ; browseable = no
  ; guest ok = yes
  [printers] //打印机设置
  comment = All Printers
  path = /var/spool/samba
  browseable = no
  printable = yes
  ;[tmp] //用户共享资源设置
  ; comment = Temporary file space
  ; path = /tmp //可以自定义目录,去掉前边的 ";" 就 OK 了
  ; read only = no //是否只读或可写
  ; public = yes
  ;[public] //用户共享资源设置
  ; comment = Public Stuff
  ; path = /home/samba
  ; public = yes
  ; writable = yes
  ; printable = no
  ; write list = @staff
  ;[fredsprn]
  ; comment = Fred's Printer
  ; valid users = fred
  ; path = /home/fred
  ; printer = freds_printer
  ; public = no
  ; writable = no
  ; printable = yes
  ;[fredsdir]
  ; comment = Fred's Service
  ; path = /usr/somewhere/private
  ; valid users = fred
  ; public = no
  ; writable = yes
  ; printable = no
  ;[pchome]
  ; comment = PC Directories
  ; path = /usr/local/pc/%m
  ; public = no
  ; writable = yes
  ;[public]
  ; path = /usr/somewhere/else/public
  ; public = yes
  ; only guest = yes
  ; writable = yes
  ; printable = no
  ;[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
  [my work] //偶的东东
  comment = is me work
  path = /root/my work
  valid users angel
  public = yes
  writeable = yes
  了解 smb.conf 的文件就好办了。我们开始对 samba server 的四个安全级别分别讲解。
  1、share 级配置
  这个在四个等级中是最低的,方法也是最简单。我们只要对 smb.conf 文件修改一下就可以了。
  workgroup = hackase
  server string = angel server
  hosts allow = 192.168.1. //限制 192.168.1 的 IP 网段可以防问
  printcap name = /etc/printcap
  load printers = yes //共享打印机
  printing = cups //打印机用 linux 标准的
  guest account = angel
  log file = /var/log/samba/%m.log
  max log size = 20
  security = share
  ===================================================================
  其他的设置默认就可以了,也可以像我把所有的注释删除。[tmp] 这个字段的 ";" 去掉.路径可以更改。 重启一下服务 /etc/samba/smb restart //
  service smb restart 也可
  用 testparm 测试我们配置的文件是否正确:
  ===================================================================
  [root@localhost root]# testparm //测试时 [printers] 注释掉了所以这里没有.
  Load smb config files from /etc/samba/smb.conf
  Processing section "[homes]"
  Processing section "[tmp]"
  Processing section "[my]"
  Loaded services file OK. //如有错误,会在这列出错误的地方。
  Press enter to see a dump of your service definitions
  ==================================================================
  用smbclient命令查看网络共享情况
  ===================================================================
  [root@localhost etc]# smbclient -L localhost //本机名为 localhost
  Password:
  Domain=[HACKBASE] OS=[Unix] Server=[Samba 2.2.7a]
  Sharename Type Comment
  --------- ---- -------
  tmp Disk Temporary file space
  my Disk is me
  IPC$ IPC IPC Service (angel server)
  ADMIN$ Disk IPC Service (angel server)
  root Printer Home Directories
  Server Comment
  --------- -------
  Workgroup Master
  --------- -------
  =======================================================================
  2、user 级配置
  user 比 share 级安全级别高一点点,很简单的,可以在 share 基础上改一下就可以了。改一下security = share 字段为:security = user。在加上如下字段:
  guest account = angel //机器上有这个用户名,如果你没有那就建一个
  encrypt passwords=yes
  smb passwd file=/etc/samba/smbpasswd
  (1)生成口令文件。
  #cat/etc/passwd | mksmbpasswd.sh>/etc/samba/smbpasswd
  本命令将生成口令文件 "/etc/samba/smbpasswd" 这个就是我们刚加上的 "smb passwd file=/etc/samba/smbpasswd"
  (2)我们知道建账户是建在 etc/passwd 文件里,我们须要用 smbpasswd 命令为刚才建立的账名设置 samba server口令。格式为:smbpasswd angel
  (3)重启 samba server 服务
  user 级的也 OK 了,你可以用 testparm and smbclient 命测试。windows 用户想访问就要输入 angel and passwd。这个就不是谁都可以访问你的共享资源了。
  3、server 级配置
  server 级比 user 级也高那么一点,只需要 user 级配置上修改一下就好了。
  (1)security = user 字段为:security = server
  (2)加上 password server = ****** //密码服务器,这个可以是你的 windows 主域控制器,也可以是别一个 samba server 服务器(名子无意思)
  (3)注释 smb passwd file=/etc/samba/smbpasswd
  (4)重启 samba server 服务,你可以用 testparm and smbclient 命测试。
  好了,又完事一个现在如果一台 windows 机器登录 ******(password server =
  ****** 设置的)域服务器的时候,也就同登录上了 samba server,如
  果你以是 ***** 主控域的计算机,那你就可以输入你自己的账号密码打开 samba server 的文件了,但是你要保证 ***** 和 sambs server 的账号和密码相同。
  4、domain 级的配置
  domain 级的配置是 samba server 中级别最高的他主要就是把 samba 加入到域中去,用域服务器作samba server 的密码服务器。
  其实 domain 级的配置也很简单,只需要在 user 级的基础上修改:
  (1)加入字段:NETBLOS = main //起一个 NETBLOS 名,放在 smb.conf 文件的最上边
  password server = ** //用主域控制器 ** 来做密码服务器
  (2)security = user 字段为:security = domain 
  workgroup = ***** //***** 是主域控制器的域名
  (3)注释 smb passwd file=/etc/samba/smbpasswd
  (4)重启 samba server 服务,你可以用 testparm and smbclient 命测试。
  终于完事了,好在我的"弹指神功"技术纯熟.这个时候我们就可以和 windows 系统通信了。可是那网络可以共享了,那么我们本机的 linux 系统和本机的 windows 系统怎么通信啊!呵呵。当然有办法,到现在大侠们可以起来活动活动了,帮我看看我写的有什么错误。好了,打开终端输入:
  [root@localhost root]# fdisk -l //查一下 windows 系统所在的分区。
  Disk /dev/hdb: 61.4 GB, 61492838400 bytes
  255 heads, 63 sectors/track, 7476 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot Start End Blocks Id System
  /dev/hdb1 * 1 738 5927953+ 7 HPFS/NTFS
  /dev/hdb2 739 7476 54122985 f Win95 Ext'd (LBA)
  /dev/hdb5 739 1480 5960083+ 7 HPFS/NTFS
  /dev/hdb6 1481 2383 7253316 b Win95 FAT32
  /dev/hdb7 3651 6200 20482843+ b Win95 FAT32
  /dev/hdb8 6201 7476 10249438+ b Win95 FAT32
  /dev/hdb9 2384 2396 104391 83 Linux
  /dev/hdb10 2397 3585 9550611 83 Linux
  /dev/hdb11 3586 3650 522081 82 Linux swap
  [root@localhost root]# mkdir /mnt/my
  //在 mnt下建一个叫 my 的目录(定义到那自己决定)
  [root@localhost root]# mount -t auto /dev/hdb7 /mnt/my //不用说了吧!
阅读(903) | 评论(0) | 转发(0) |
0

上一篇:绝对暴笑

下一篇:妈妈的粥

给主人留下些什么吧!~~