crossz

Archive for November 11th, 2007

SMB:Configuring your computer as a server

In howto, linux, server on November 11, 2007 at 4:09 pm

A fairly comprehensive graphical Samba configuration tool is available for KDE, by installing the “kdenetwork-filesharing” package. Once install, you can find it by launching the KDE Control Center. (Alt-F2 and then type kcontrol). Browse to Internet & Network > Samba. It is fairly easy to use.

A less friendly but also graphical tool is Swat, a web-based interface.

The following tips show how to do some basic things without installing additional software, using the command line. It is not difficult, just be careful with typos.

First open a terminal: Applications > System Tools > Terminal and open the file smb.conf

sudo nano -w /etc/samba/smb.conf

How to Save: To save in nano use “ctrl/o” than “ctrl/x”.

Tip: Replacing nano with gedit gives you a nice graphical editor.

The file *smb.conf* is divided in several sections:

Global SettingsDebugging/AccountingAuthenticationPrintingFile sharingMiscShare Definitions

Let’s start with Global Settings. Here you will see several lines, which you can also see in the graphical networktool like workgroup and wins server. If you changed everything to your liking already then you can skip this section, if not change to what you need. If you do not know what items mean, leave them be and read the [WWW] relevant part in the real Samba-howto instead of randomly changing them. It will save you trouble-shooting later.

The important part for us is File sharing. We need to change:

[homes]comment = Home Directoriesbrowseable = no

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = no

This describes your /home folder. Usually you want to share this folder in a home-environment, because these are the files you want to share. To do so, make the following changes:

[homes]comment = Home Directoriesbrowseable = yes

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = yes

This finishes sharing your /home folder. The last thing we need to do is fixing a user.

Add users who can access your shares with the ’smbpasswd’ command.

sudo  smbpasswd -a username

New SMB password:Retype new SMB password:Added user username.

NOTE: the username used here should be a real user setup on your PC/Server. Reload Samba for every change to users/passwords or ’smb.conf’

sudo /etc/init.d/samba reload

That’s the basis of Samba file-sharing. Please leave your comments about what else is needed here.

Back to top

Complicating things a little

We started with the base of Samba file-sharing. The above-mentioned items should be enough to get you started. Next we will add details that you might or might not need.

Back to top

If you have more the one networkcard

If you have more the one networkcard (or interface) then you have to define where you want Samba to run. In smb.conf under the [global] section, add:

"interfaces = 127.0.0.1, 192.168.0.31/24""bind interfaces only = yes"

The first address (127.0.0.1), is a loopback network connection (it’s your own machine). The second address (192.168.0.31), is the address of the card you want Samba to run on, the second number (24) is the subnet default for a CLASS-C network. It may vary depending on your network.

With “bind interfaces only” you limit which interfaces on a machine will serve SMB requests.

You can limit which IP address can connect to your Samba server adding these lines:

"hosts allow = 127.0.0.1, 192.168.0.31, 192.168.0.32""hosts deny = 0.0.0.0/0"

The loopback address must be present in the first line. The second line deny access from all IP address not in the first line.

Back to top

Sharing CUPS Printers

If You would like to share Your printers make the following changes to Samba:

If not already done create the Samba-user You want the share to be used by.

In smb.conf uncomment and change the lines ending up with the following configuration:

########## Printing ##########

# If you want to automatically load your printer list rather# than setting them up individually then you'll need this  load printers = yes

# [...] // Some BSD printing stuff, do not edit if You do not need to

# CUPS printing.  See also the cupsaddsmb(8) manpage in the# cupsys-client package.  printing = cups  printcap name = cups

and in the Share Definitions section append and/or modify the [printers] part ending up like this:

# ======================= Share Definitions =======================# [...] // File and Folder sharing, do not edit if You do not need to

[printers]  comment = All Printers  browseable = no  path = /tmp  printable = yes  public = yes  writable = no  create mode = 0700  printcap name = /etc/printcap  print command = /usr/bin/lpr -P%p -r %s  printing = cups

Some explanation what is done:

the [printers] part defines the default-behavior for all the printers that are mentioned in “printcap name”. A sort of template how to create shares for these printers. This template is applied if “load printers” is set to true. For more detailed explanation refer to the Samba documentation.

And do not forget to reload Samba:

sudo /etc/init.d/samba reload

Back to top

SMB:Configuring your computer as a server

In howto, linux, server on November 11, 2007 at 4:09 pm

A fairly comprehensive graphical Samba configuration tool is available for KDE, by installing the “kdenetwork-filesharing” package. Once install, you can find it by launching the KDE Control Center. (Alt-F2 and then type kcontrol). Browse to Internet & Network > Samba. It is fairly easy to use.

A less friendly but also graphical tool is Swat, a web-based interface.

The following tips show how to do some basic things without installing additional software, using the command line. It is not difficult, just be careful with typos.

First open a terminal: Applications > System Tools > Terminal and open the file smb.conf

sudo nano -w /etc/samba/smb.conf

How to Save: To save in nano use “ctrl/o” than “ctrl/x”.

Tip: Replacing nano with gedit gives you a nice graphical editor.

The file *smb.conf* is divided in several sections:

Global SettingsDebugging/AccountingAuthenticationPrintingFile sharingMiscShare Definitions

Let’s start with Global Settings. Here you will see several lines, which you can also see in the graphical networktool like workgroup and wins server. If you changed everything to your liking already then you can skip this section, if not change to what you need. If you do not know what items mean, leave them be and read the [WWW] relevant part in the real Samba-howto instead of randomly changing them. It will save you trouble-shooting later.

The important part for us is File sharing. We need to change:

[homes]comment = Home Directoriesbrowseable = no

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = no

This describes your /home folder. Usually you want to share this folder in a home-environment, because these are the files you want to share. To do so, make the following changes:

[homes]comment = Home Directoriesbrowseable = yes

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = yes

This finishes sharing your /home folder. The last thing we need to do is fixing a user.

Add users who can access your shares with the ’smbpasswd’ command.

sudo  smbpasswd -a username

New SMB password:Retype new SMB password:Added user username.

NOTE: the username used here should be a real user setup on your PC/Server. Reload Samba for every change to users/passwords or ’smb.conf’

sudo /etc/init.d/samba reload

That’s the basis of Samba file-sharing. Please leave your comments about what else is needed here.

Back to top

Complicating things a little

We started with the base of Samba file-sharing. The above-mentioned items should be enough to get you started. Next we will add details that you might or might not need.

Back to top

If you have more the one networkcard

If you have more the one networkcard (or interface) then you have to define where you want Samba to run. In smb.conf under the [global] section, add:

"interfaces = 127.0.0.1, 192.168.0.31/24""bind interfaces only = yes"

The first address (127.0.0.1), is a loopback network connection (it’s your own machine). The second address (192.168.0.31), is the address of the card you want Samba to run on, the second number (24) is the subnet default for a CLASS-C network. It may vary depending on your network.

With “bind interfaces only” you limit which interfaces on a machine will serve SMB requests.

You can limit which IP address can connect to your Samba server adding these lines:

"hosts allow = 127.0.0.1, 192.168.0.31, 192.168.0.32""hosts deny = 0.0.0.0/0"

The loopback address must be present in the first line. The second line deny access from all IP address not in the first line.

Back to top

Sharing CUPS Printers

If You would like to share Your printers make the following changes to Samba:

If not already done create the Samba-user You want the share to be used by.

In smb.conf uncomment and change the lines ending up with the following configuration:

########## Printing ##########

# If you want to automatically load your printer list rather# than setting them up individually then you'll need this  load printers = yes

# [...] // Some BSD printing stuff, do not edit if You do not need to

# CUPS printing.  See also the cupsaddsmb(8) manpage in the# cupsys-client package.  printing = cups  printcap name = cups

and in the Share Definitions section append and/or modify the [printers] part ending up like this:

# ======================= Share Definitions =======================# [...] // File and Folder sharing, do not edit if You do not need to

[printers]  comment = All Printers  browseable = no  path = /tmp  printable = yes  public = yes  writable = no  create mode = 0700  printcap name = /etc/printcap  print command = /usr/bin/lpr -P%p -r %s  printing = cups

Some explanation what is done:

the [printers] part defines the default-behavior for all the printers that are mentioned in “printcap name”. A sort of template how to create shares for these printers. This template is applied if “load printers” is set to true. For more detailed explanation refer to the Samba documentation.

And do not forget to reload Samba:

sudo /etc/init.d/samba reload

Back to top

SMB vs NFS

In howto, linux, server on November 11, 2007 at 1:41 am

SMB是Server Messege Block的缩写,其实就是实现Windows文件和打印共享的基础协议,后来在*nix下通过samba实现了smb协议,所以可以达成不同系统之间的文件和打印共享互通。
而NFS是在内核级别实现的Network File System。通过NFS协议import的分区,可以当成本机的磁盘来使用。所有读写都是内核负责,所以效率上比SMB要好,但是仅仅能实现文件读写,没有打印服务。

smb service

In howto, linux, server on November 11, 2007 at 1:35 am
为了实现windows 和 Linux以及其他操作系统之间的资源共享,软件商推出nfs
和samba两种解决方式。由于市场上缺乏象pc-nfs那样的客户端工具,使得Linux和windows的资源共享变得复杂。Samba的出现解决了
这一问题,它以其简洁、实用、灵活配置的特点受到越来越多人们的广泛关注。

  Windows利用SMB协议来实现操作系统间文件和打印机共享,而Samba本身具备SMB协议,它实现局域网内和Windows系列计算机的资源共享。

  本文就Samba在Linux系统下的配置为重点,讨论局域网内windows 与 Linux 的资源共享。

  一、Samba 介绍

  1、SMB协议

 
 SMB (Server Message Block,服务信息块)
协议,是局域网上的共享文件/打印机的一种协议,它可以为网络内部的其他windows和linux
机器提供文件系统、打印服务。SMB的工作原理是让NetBIOS和SMB运行在TCP/IP之上,且使用NetBIOS的nameserver让
linux机器可以在windows 网络邻居里被浏览。

  2、Samba

  Samba是用来实现SMB的一种软件,由澳大利亚的Andew Tridgell开发,是一种在Linux 环境里运行的自由软件。它可以完成如下功能:

  文件服务和打印服务,实现Windows和Linux的资源共享。

  登录服务器,可以作为局域网的服务器。

  作为主域控制器。

  WINS服务器。

  支持SSL。

  支持SWAT。

  二、 Samba服务

  1、 核心进程

  Samba 有两个守护进程:smbd 和nmbd,它们是Samba的核心进程。nmbd进程使其他计算机浏览Linux服务器,Smbd进程在SMB服务请求到达时对它们进行处理,并且为使用或共享的资源进行协调。

smbd 是提供数据传输服务,也就是我们说的Samba服务的主要功能
nmbd 是提供名称解析服务的,就是说开启此服务我们可以通过主机名来访问共享目录

  2、 启动服务

  Samba 有两种启动方式:Daemon形式和Inetd形式。

  (1)Daemon形式 建立启动脚本:rc.samba

  smbd -D -d1

  nmbd -D -d1

  -D 表示以Daemon形式执行;-d1 表示除错记录级别

  执行脚本文件rc.samba

  (2)Inetd形式

  设置文件:/etc/services

  netbios -ssn 139/ tcp

  netbios -ns 137/ udp

  设置文件:/etc/inetd.conf

  netbios -ssn stream tcp nowait root /usr/sbin/smbd smbd

  netbios -ns dgram udp wait root /usr/sbin/nmbd nmbd

  重启动Inetd daemon

  # kill -HUP 1

  3、 客户工具 smbclient

  Smbclient命令用来存取远程Samba服务器上的资源。其命令形式与ftp相似。

  命令语法是:#smbclient [password] [option]

  (1) 解释:servicename是要连接的资源名称,资源名称的形式如下:

  //server/service server 是远程服务器的NetBIOS名字,对于windows服务器而言,就是出现在网上邻居中的名字。

  Service是各server所提供的资源的名字。

  pssword 是存取该资源所需的口令

  option 各种命令选项,其中 -L 用于列出远程服务器提供的所有资源

  -I 指定远程服务器的IP地址。此时,servicesname 中的NetBIOS名部分将被忽略。

  (2)多种smbclient命令:

  执行smbclient命令成功后,进入smbclient环境,出现提示符: smb:\>

  这里有许多命令和ftp命令相似,如cd 、lcd、get、megt、put、mput等。通过这些命令,我们可以访问远程主机的共享资源。

  4、 Samba系统装载与卸载

  (1) 装载其他主机的资源

  我们可以利用Samba提供的smbmount命令,装载其他主机的共享资源。

  Smbmount的命令语法:# smbmount

  其中 servicename 是资源名,mount-point是安装点。

  例如: # smbmount “\\server\tmp” -c ‘ mount /mnt’

  表示:把名字为“server”的计算机上的共享资源“tmp”的内容装载到本地的 /mnt

  目录下。

  (2) 卸载资源

  卸载一个已经装载的SMB文件系统,使用smbunmount命令,同时指定要卸载的装载点。 例如: # smbunmount / mnt

  三、Samba配置

  Samba组件的配置文件是 /etc/smb.conf ,该文件几乎包含了Samba系统程序运行时所需的所有配置信息。

  1、 配置选项

  配置文件中有比较重要的几个节:[gloabal]、[homes]、[printers],下面分别给与说明。

  (1)[gloabal]节 在全局参数中,参数的设置直接影响samba系统。

  NetBIOS name:设置主机名称

  Workgroup:用来指定主机所在网络上所属的NT域名或者工作组名称。格式是

  Workgroup= Nt Domain-Name or workgroup-name

  Server string:用来设置本机描述,缺省是 Samba Server

  Host Allow:它允许设置哪些领域的机器可以访问它的Samba服务器

  Load printers:允许自动加载打印机列表,而不需要单独设置每一台打印机。

  Interface:配置Samba使用多个网络界面。

  Domain controller: 仅当网络中有一台在安装时设置为主域控制器时使用此选项。

  Security: 设置安全参数,定义安全模式。Samba 的安全模式有四种

  Share、 user、 server 、domain

  encrypt passwords 、smb passwd file:用于适用加密口令。

  下面是一段参数配置例子:

  [global]

  smb passwd file = /etc/smbpasswd

  remote announce = 172.18.158.234 172.18.153.55 172.18.153.255

  dns proxy = no

  security = user

  encrypt passwords = yes

  server string = Ftp Server

  workgroup = turing

  socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  log file = /var/log/samba/log.%m

  load printers = yes

  guest account = dscan

  remote browse sync = 172.18.158.234 172.18.153.55 172.18.153.255

  printcap name = /etc/printcap

  max log size = 50

  hosts allow = 172.18.158. 172.18.153. 127.

  … …

  (2)[homes]节 所有使用者的home目录

  当任何一个客户访问Samba服务器时,在网络资源中都能出现自己的home目录共享。其配置如下:

  [homes]

  comment = Hnnw Directories

  browseable = no

  writable = yes

  (3)用户共享目录

  用来指定某一特定用户组或者用户拥有访问权限的目录配置,下列参数配置仅有hnnw组的用户有权访问目录/home/samba。

  [public]

  comment = Public Hnnw

  path = /home/samba

  public = yes

  writable = yes

  printable = no

  write list = @hnnw

  2、 用户映射

  全局参数“username map”用来控制用户映射,它允许管理员指定一个映射文件,该文件包含了在客户机和服务器之间进行用户映射的信息。

  如:username map= /etc/smbuser

  用户映射经常在windows 和linux 主机间进行。 两个系统拥有不同的用户账号,用户映射的目的是将不同的用户映射成为一个用户,便于共享文件。

  下面是一个映射文件的例子:

  # Map Windows admin to root

  root=admin administrator

  ;Map the member of developer to studio

  studio = @developer

  等号左边是单独的Linux账号,等号右边是要映射的账号列表。

  服务器逐行分析映射文件,如果提供的账号和某行有右侧列表中的账号匹配,就把它

  替换为等号左边的账号。

  3、 使用加密口令

 
 新版本的windows
95以及windows98、winnt(sp3以上版本),在网络传输中仅传递加密口令作为用户认证的信息。这类客户机和不支持加密口令并且以user
安全级运行的Samba服务器通讯时,会出现故障。为了正常的通讯,samba服务器使用加密口令。下面讨论如何在samba中使用加密口令。

  (1) 口令文件 /etc/smbpasswd

  为了使用加密口令,samba 需要一份口令文件(/etc/smbpasswd),并且该文件应该和Linux的口令文件(/etc/passwd)保持同步。下面是生成文件命令:

  # cat /etc/password | mksmbpasswd >/etc/smbpasswd

  smbpasswd 是需要的口令文件,其权限是0600,所有者是root

  smbpasswd和passwd文件的记录对应,密码部分不同。密码有两部分组成,每部分

  是32个”X”,前部分用于和Lanman通讯,后部分和Windows NT通讯。

  Root用户可以使用smbpasswd命令为每个用户设定samba口令。

  (2) 修改配置文件 /etc/smb.conf

  要使Samba使用加密口令,需要在配置文件smb.conf中加入如下参数。

  Encrypt passwords=yes

  Smb passwd file= /etc/smbpasswd

  第一行通知samba使用加密口令,第二行给出口令文件的位置。

  (3) 重启动samba 服务。

  修改完配置文件后,需要重新启动samba服务,可用如下命令:

  # /usr/sbin/samba restart

  4、windows系统中的明码口令使用

 
 Samba系统中使用明码口令作为连接SMB的默认设置。当SMB服务器对协商协议做出响应时,响应信息包含了一位,以说明服务器是否支持询问或者响应

密。随着win95的网络重定向更新程序的发布,Microsoft修改了默认值,这样,windows客户就不会向不支持加密的服务器发送明码口令了。

  在这种情况下,有两种解决办法:

  (1)设置Samba服务器使用加密口令

  (2)让windows客户使用明码口令

  这里选用第2种解决办法,通过修改注册表来实现。下面对win95/win98、winnt用户分别给与说明。

  (1)win98/win95系统用户

  在注册表中加入下列注册字,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\VxD\VNETSUP]

  “EnablePlainTextPAssword”= dword:00000001

  (2)Winnt系统用户

  修改注册表,加入下列注册表项,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\Rdr\Parameters]

  “EnablePlainTextPAssword”= dword:00000001

  四、Samba应用

  1、 windows资源共享与使用

  (1)windows资源共享

  a. 使用TCP/IP协议作为网络默认通讯协议

  b. 修改网络配置,设置文件和打印机共享。

  c. 设置好计算机名和所属工作组

  d.共享系统资源

  (2)在windows系统中使用Linux共享资源

  a. 登录进入windows网络

  b. 通过网上邻居查看、使用共享资源。

  c. 命令行下工具使用共享资源

  使用命令行下的net.txt工具来查看、使用共享资源:

  net use 命令的语法: c:>net use X:\\servername\sharename

  在这里,X:是共享的驱动器盘符,\\servername\sharename是到共享的UNC的网络路径。

  例如: c:\>net use h:\\hey\myfile

  表示:将hey机器上的myfile共享资源映射为本地的h盘

  2、Linux资源共享与使用

  (1)将Linux 的资源共享

  通过编辑Samba配置文件,添加需要共享的Linux资源。同时可以设定访问此资源的用户群及其访问权限。下面是一段例子,将本机的 /public/data 目录共享,所有人都有读写权限。

  [data]

  comment = Public Data

  path = /public/data

  public = yes

  writable = yes

  printable = no

  (2)在Linux中使用共享资源

  可以使用smbclient命令,访问所有的Samba资源。具体使用方法见前述。

  五、Samba应用程序

  smbclient :访问所有共享资源

  smbstatus: 列出当前所有的samba连接状态

  smbpasswd:修改samba用户口令、增加samba用户。

  Nmblookup:用于查询主机的NetBIOS名,并将其映射为IP地址

  Testparam: 用于检查配置文件中的参数设置是否正确

  Linux 系统中的Samba配置

Powered by ScribeFire.

smb service

In howto, linux, server on November 11, 2007 at 1:35 am
为了实现windows 和 Linux以及其他操作系统之间的资源共享,软件商推出nfs
和samba两种解决方式。由于市场上缺乏象pc-nfs那样的客户端工具,使得Linux和windows的资源共享变得复杂。Samba的出现解决了
这一问题,它以其简洁、实用、灵活配置的特点受到越来越多人们的广泛关注。

  Windows利用SMB协议来实现操作系统间文件和打印机共享,而Samba本身具备SMB协议,它实现局域网内和Windows系列计算机的资源共享。

  本文就Samba在Linux系统下的配置为重点,讨论局域网内windows 与 Linux 的资源共享。

  一、Samba 介绍

  1、SMB协议

 
 SMB (Server Message Block,服务信息块)
协议,是局域网上的共享文件/打印机的一种协议,它可以为网络内部的其他windows和linux
机器提供文件系统、打印服务。SMB的工作原理是让NetBIOS和SMB运行在TCP/IP之上,且使用NetBIOS的nameserver让
linux机器可以在windows 网络邻居里被浏览。

  2、Samba

  Samba是用来实现SMB的一种软件,由澳大利亚的Andew Tridgell开发,是一种在Linux 环境里运行的自由软件。它可以完成如下功能:

  文件服务和打印服务,实现Windows和Linux的资源共享。

  登录服务器,可以作为局域网的服务器。

  作为主域控制器。

  WINS服务器。

  支持SSL。

  支持SWAT。

  二、 Samba服务

  1、 核心进程

  Samba 有两个守护进程:smbd 和nmbd,它们是Samba的核心进程。nmbd进程使其他计算机浏览Linux服务器,Smbd进程在SMB服务请求到达时对它们进行处理,并且为使用或共享的资源进行协调。

smbd 是提供数据传输服务,也就是我们说的Samba服务的主要功能
nmbd 是提供名称解析服务的,就是说开启此服务我们可以通过主机名来访问共享目录

  2、 启动服务

  Samba 有两种启动方式:Daemon形式和Inetd形式。

  (1)Daemon形式 建立启动脚本:rc.samba

  smbd -D -d1

  nmbd -D -d1

  -D 表示以Daemon形式执行;-d1 表示除错记录级别

  执行脚本文件rc.samba

  (2)Inetd形式

  设置文件:/etc/services

  netbios -ssn 139/ tcp

  netbios -ns 137/ udp

  设置文件:/etc/inetd.conf

  netbios -ssn stream tcp nowait root /usr/sbin/smbd smbd

  netbios -ns dgram udp wait root /usr/sbin/nmbd nmbd

  重启动Inetd daemon

  # kill -HUP 1

  3、 客户工具 smbclient

  Smbclient命令用来存取远程Samba服务器上的资源。其命令形式与ftp相似。

  命令语法是:#smbclient [password] [option]

  (1) 解释:servicename是要连接的资源名称,资源名称的形式如下:

  //server/service server 是远程服务器的NetBIOS名字,对于windows服务器而言,就是出现在网上邻居中的名字。

  Service是各server所提供的资源的名字。

  pssword 是存取该资源所需的口令

  option 各种命令选项,其中 -L 用于列出远程服务器提供的所有资源

  -I 指定远程服务器的IP地址。此时,servicesname 中的NetBIOS名部分将被忽略。

  (2)多种smbclient命令:

  执行smbclient命令成功后,进入smbclient环境,出现提示符: smb:\>

  这里有许多命令和ftp命令相似,如cd 、lcd、get、megt、put、mput等。通过这些命令,我们可以访问远程主机的共享资源。

  4、 Samba系统装载与卸载

  (1) 装载其他主机的资源

  我们可以利用Samba提供的smbmount命令,装载其他主机的共享资源。

  Smbmount的命令语法:# smbmount

  其中 servicename 是资源名,mount-point是安装点。

  例如: # smbmount “\\server\tmp” -c ‘ mount /mnt’

  表示:把名字为“server”的计算机上的共享资源“tmp”的内容装载到本地的 /mnt

  目录下。

  (2) 卸载资源

  卸载一个已经装载的SMB文件系统,使用smbunmount命令,同时指定要卸载的装载点。 例如: # smbunmount / mnt

  三、Samba配置

  Samba组件的配置文件是 /etc/smb.conf ,该文件几乎包含了Samba系统程序运行时所需的所有配置信息。

  1、 配置选项

  配置文件中有比较重要的几个节:[gloabal]、[homes]、[printers],下面分别给与说明。

  (1)[gloabal]节 在全局参数中,参数的设置直接影响samba系统。

  NetBIOS name:设置主机名称

  Workgroup:用来指定主机所在网络上所属的NT域名或者工作组名称。格式是

  Workgroup= Nt Domain-Name or workgroup-name

  Server string:用来设置本机描述,缺省是 Samba Server

  Host Allow:它允许设置哪些领域的机器可以访问它的Samba服务器

  Load printers:允许自动加载打印机列表,而不需要单独设置每一台打印机。

  Interface:配置Samba使用多个网络界面。

  Domain controller: 仅当网络中有一台在安装时设置为主域控制器时使用此选项。

  Security: 设置安全参数,定义安全模式。Samba 的安全模式有四种

  Share、 user、 server 、domain

  encrypt passwords 、smb passwd file:用于适用加密口令。

  下面是一段参数配置例子:

  [global]

  smb passwd file = /etc/smbpasswd

  remote announce = 172.18.158.234 172.18.153.55 172.18.153.255

  dns proxy = no

  security = user

  encrypt passwords = yes

  server string = Ftp Server

  workgroup = turing

  socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  log file = /var/log/samba/log.%m

  load printers = yes

  guest account = dscan

  remote browse sync = 172.18.158.234 172.18.153.55 172.18.153.255

  printcap name = /etc/printcap

  max log size = 50

  hosts allow = 172.18.158. 172.18.153. 127.

  … …

  (2)[homes]节 所有使用者的home目录

  当任何一个客户访问Samba服务器时,在网络资源中都能出现自己的home目录共享。其配置如下:

  [homes]

  comment = Hnnw Directories

  browseable = no

  writable = yes

  (3)用户共享目录

  用来指定某一特定用户组或者用户拥有访问权限的目录配置,下列参数配置仅有hnnw组的用户有权访问目录/home/samba。

  [public]

  comment = Public Hnnw

  path = /home/samba

  public = yes

  writable = yes

  printable = no

  write list = @hnnw

  2、 用户映射

  全局参数“username map”用来控制用户映射,它允许管理员指定一个映射文件,该文件包含了在客户机和服务器之间进行用户映射的信息。

  如:username map= /etc/smbuser

  用户映射经常在windows 和linux 主机间进行。 两个系统拥有不同的用户账号,用户映射的目的是将不同的用户映射成为一个用户,便于共享文件。

  下面是一个映射文件的例子:

  # Map Windows admin to root

  root=admin administrator

  ;Map the member of developer to studio

  studio = @developer

  等号左边是单独的Linux账号,等号右边是要映射的账号列表。

  服务器逐行分析映射文件,如果提供的账号和某行有右侧列表中的账号匹配,就把它

  替换为等号左边的账号。

  3、 使用加密口令

 
 新版本的windows
95以及windows98、winnt(sp3以上版本),在网络传输中仅传递加密口令作为用户认证的信息。这类客户机和不支持加密口令并且以user
安全级运行的Samba服务器通讯时,会出现故障。为了正常的通讯,samba服务器使用加密口令。下面讨论如何在samba中使用加密口令。

  (1) 口令文件 /etc/smbpasswd

  为了使用加密口令,samba 需要一份口令文件(/etc/smbpasswd),并且该文件应该和Linux的口令文件(/etc/passwd)保持同步。下面是生成文件命令:

  # cat /etc/password | mksmbpasswd >/etc/smbpasswd

  smbpasswd 是需要的口令文件,其权限是0600,所有者是root

  smbpasswd和passwd文件的记录对应,密码部分不同。密码有两部分组成,每部分

  是32个”X”,前部分用于和Lanman通讯,后部分和Windows NT通讯。

  Root用户可以使用smbpasswd命令为每个用户设定samba口令。

  (2) 修改配置文件 /etc/smb.conf

  要使Samba使用加密口令,需要在配置文件smb.conf中加入如下参数。

  Encrypt passwords=yes

  Smb passwd file= /etc/smbpasswd

  第一行通知samba使用加密口令,第二行给出口令文件的位置。

  (3) 重启动samba 服务。

  修改完配置文件后,需要重新启动samba服务,可用如下命令:

  # /usr/sbin/samba restart

  4、windows系统中的明码口令使用

 
 Samba系统中使用明码口令作为连接SMB的默认设置。当SMB服务器对协商协议做出响应时,响应信息包含了一位,以说明服务器是否支持询问或者响应

密。随着win95的网络重定向更新程序的发布,Microsoft修改了默认值,这样,windows客户就不会向不支持加密的服务器发送明码口令了。

  在这种情况下,有两种解决办法:

  (1)设置Samba服务器使用加密口令

  (2)让windows客户使用明码口令

  这里选用第2种解决办法,通过修改注册表来实现。下面对win95/win98、winnt用户分别给与说明。

  (1)win98/win95系统用户

  在注册表中加入下列注册字,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\VxD\VNETSUP]

  “EnablePlainTextPAssword”= dword:00000001

  (2)Winnt系统用户

  修改注册表,加入下列注册表项,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\Rdr\Parameters]

  “EnablePlainTextPAssword”= dword:00000001

  四、Samba应用

  1、 windows资源共享与使用

  (1)windows资源共享

  a. 使用TCP/IP协议作为网络默认通讯协议

  b. 修改网络配置,设置文件和打印机共享。

  c. 设置好计算机名和所属工作组

  d.共享系统资源

  (2)在windows系统中使用Linux共享资源

  a. 登录进入windows网络

  b. 通过网上邻居查看、使用共享资源。

  c. 命令行下工具使用共享资源

  使用命令行下的net.txt工具来查看、使用共享资源:

  net use 命令的语法: c:>net use X:\\servername\sharename

  在这里,X:是共享的驱动器盘符,\\servername\sharename是到共享的UNC的网络路径。

  例如: c:\>net use h:\\hey\myfile

  表示:将hey机器上的myfile共享资源映射为本地的h盘

  2、Linux资源共享与使用

  (1)将Linux 的资源共享

  通过编辑Samba配置文件,添加需要共享的Linux资源。同时可以设定访问此资源的用户群及其访问权限。下面是一段例子,将本机的 /public/data 目录共享,所有人都有读写权限。

  [data]

  comment = Public Data

  path = /public/data

  public = yes

  writable = yes

  printable = no

  (2)在Linux中使用共享资源

  可以使用smbclient命令,访问所有的Samba资源。具体使用方法见前述。

  五、Samba应用程序

  smbclient :访问所有共享资源

  smbstatus: 列出当前所有的samba连接状态

  smbpasswd:修改samba用户口令、增加samba用户。

  Nmblookup:用于查询主机的NetBIOS名,并将其映射为IP地址

  Testparam: 用于检查配置文件中的参数设置是否正确

  Linux 系统中的Samba配置

Powered by ScribeFire.

NFS service

In howto, linux, server on November 11, 2007 at 1:16 am
Linux服务配置文档—NFS – wds

NFS为network file system 的简称,最早由sun公司开发,一般NFS广泛应用在集群服务器上,他的最大特点是可以通过网络让不同的机器,不同的操作系统可以彼此的共享文件,所以它可以看作一个简单的文件服务器。NFS其实可以被视为一个RPC服务程序,在启动RPC程序前我们先要做好端口的映射工作这就是portmap,portmap的意思是当Client要连接服务器时必须知道服务器的一个空闲端口这时Client会向服务器的portmap请求一个端口然,然后Server告诉Client这端口后才可以建立连接,所以在启动NFS前要先启动portmap

[wds@localhost ~]# rpm –qa |grep nfs && rpm –qa | grep portmap #查找这两个是否安装

[wds@localhost ~]# vi /etc/exports # 这文件是NFS的主要配置文件

[wds@localhost ~]# /usr/sbin/exportfs #这个文件是nfs共享资源命令

[wds@localhost ~]# /usr/sbin/showmount #可以查看远程服务器的共享目录

[wds@localhost ~]# /var/lib/nfs/xtab #nfs 的日志文件

[wds@localhost ~]# vi /etc/exports

[你想要的共享的目录] + ip 地址(参数一,参数二) [主机名二](参数三,参数四)

参数列表

rw: 可以写入权限

ro: 只读权限

no_root_squash: 登陆NFS主机共享目录的如果是root用户那么那的权限也为root但是这样并不安全

root_squash: 登陆的用户如果为root它的权限将变成nobody

all_squash: 不论登陆的用户是什么用户都以匿名用户的权限

sync: 数据同步写入硬盘和内存中

async: 数据先暂时存放在内存中,而不写入硬盘

anounid: 这个可以自己设定uid,但是必须与/etc/passwd目录中用户uid一样

anongid: 同anonuid,但是变的是group id

服务器端配置

[wds@localhost ~]# service portmap start #首先打开portmap

[wds@localhost ~]# service nfs start # 在打开 nfs

[wds@localhost ~]#i iptables –F #清空防火墙命令

[wds@localhost ~]#

比如说我要共享/var/www/html 目录 但是只是让和我一个网段的机器访问192.168.0.0/24这个网段读或写,其他的就只能读,然后在发布一个私人目录/home/wds/只开放给192.168.0.8

这个IP

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

现在想要*.chinaunix.com网段的机器登陆我的NFS,并且访问我的/home/wds/ 但是它们存储时我希望它们的uid和gid都变成40这个用户身份

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

/home/wds *.chinaunix.com(rw,all)squash,anounid=40,anongid=40)

如果我们修改/etc/exports这个文件后,是否要从新启动nfs呢?答案是不不需要,只要使用exportfs来从新扫描一次/etc/exports文件,并且从新设置文件加载即可

语法为:

[wds@localhost ~]# exportfs [-aruv]

参数说明:

-a: 全部挂载(或者卸载)/etc/exports 文件的设置

-r: 从新挂载/etc/exports 里设置,此外,同步更新/etc/exports 及/var/lib/nfs/xtab的内容

-u: 卸载某一目录

-v: 在导出时,将共享目录显示在屏幕上

例如:

[wds@localhost ~]# exportfs –rv 全部从新导出一次

[wds@localhost ~]# exportfs –au 全部卸载掉

Showmount 的是显示是否有挂载

语法为:

[wds@localhost ~]# showmount [-ae] hostname

参数说明:

-a: 在屏幕上显示与当前的client连接后使用目录的状态

-e: 显示Hostname这台机器的/etc/exports中的共享信息

[wds@localhost log]# showmount -e localhost

Export list for localhost:

/var/www/html (everyone)

Rpcinfo [-p]hostname[or ip]

-p 显示端口与程序的信息

[wds@localhost log]# rpcinfo -p localhost

program vers proto port

100000 2 tcp 111 portmapper

100000 2 udp 111 portmapper

100024 1 udp 1024 status

100024 1 tcp 1024 status

100011 1 udp 837 rquotad

100011 2 udp 837 rquotad

100011 1 tcp 840 rquotad

100011 2 tcp 840 rquotad

100003 2 udp 2049 nfs

100003 3 udp 2049 nfs

100003 4 udp 2049 nfs

100003 2 tcp 2049 nfs

100003 3 tcp 2049 nfs

100003 4 tcp 2049 nfs

100021 1 udp 1026 nlockmgr

100021 3 udp 1026 nlockmgr

100021 4 udp 1026 nlockmgr

100021 1 tcp 1026 nlockmgr

100021 3 tcp 1026 nlockmgr

100021 4 tcp 1026 nlockmgr

100005 1 udp 858 mountd

100005 1 tcp 861 mountd

100005 2 udp 858 mountd

100005 2 tcp 861 mountd

100005 3 udp 858 mountd

100005 3 tcp 861 mountd

Client端的设置

Server端设置完毕,接下来就是让client端连接上server!连接server步骤如下:

1. 扫描可以使用的server目录:

2. 在client端建立装载点

3. 使用mount 命令远程挂载远程共享目录

4. 解决可能发生的问题(被防火墙过滤掉了)

Showmount是显示远程主机共享资源

[wds@localhost ~]# showmount -e 192.168.0.8

Export list for 192.168.0.8:

/var/www/html (everyone)

/home/wds *.chinaunix.com,192.168.0.6

[wds@localhost ~]# mount -t nfs 192.168.0.8:/var/www/html /mnt 把远程的/var/www/html 挂载到本地

[wds@localhost ~]# umount /mnt 卸载远程目录

如果你想要开机启动时自动加载NFS服务器导出目录,我们在NFS端/etc/fstab文件中加入以下一行

192.168.0.8:/var/www/html /mnt nfs rsize=8192,wsize=8192,timeo=14,intr

Powered by ScribeFire.

NFS service

In howto, linux, server on November 11, 2007 at 1:16 am
Linux服务配置文档—NFS – wds

NFS为network file system 的简称,最早由sun公司开发,一般NFS广泛应用在集群服务器上,他的最大特点是可以通过网络让不同的机器,不同的操作系统可以彼此的共享文件,所以它可以看作一个简单的文件服务器。NFS其实可以被视为一个RPC服务程序,在启动RPC程序前我们先要做好端口的映射工作这就是portmap,portmap的意思是当Client要连接服务器时必须知道服务器的一个空闲端口这时Client会向服务器的portmap请求一个端口然,然后Server告诉Client这端口后才可以建立连接,所以在启动NFS前要先启动portmap

[wds@localhost ~]# rpm –qa |grep nfs && rpm –qa | grep portmap #查找这两个是否安装

[wds@localhost ~]# vi /etc/exports # 这文件是NFS的主要配置文件

[wds@localhost ~]# /usr/sbin/exportfs #这个文件是nfs共享资源命令

[wds@localhost ~]# /usr/sbin/showmount #可以查看远程服务器的共享目录

[wds@localhost ~]# /var/lib/nfs/xtab #nfs 的日志文件

[wds@localhost ~]# vi /etc/exports

[你想要的共享的目录] + ip 地址(参数一,参数二) [主机名二](参数三,参数四)

参数列表

rw: 可以写入权限

ro: 只读权限

no_root_squash: 登陆NFS主机共享目录的如果是root用户那么那的权限也为root但是这样并不安全

root_squash: 登陆的用户如果为root它的权限将变成nobody

all_squash: 不论登陆的用户是什么用户都以匿名用户的权限

sync: 数据同步写入硬盘和内存中

async: 数据先暂时存放在内存中,而不写入硬盘

anounid: 这个可以自己设定uid,但是必须与/etc/passwd目录中用户uid一样

anongid: 同anonuid,但是变的是group id

服务器端配置

[wds@localhost ~]# service portmap start #首先打开portmap

[wds@localhost ~]# service nfs start # 在打开 nfs

[wds@localhost ~]#i iptables –F #清空防火墙命令

[wds@localhost ~]#

比如说我要共享/var/www/html 目录 但是只是让和我一个网段的机器访问192.168.0.0/24这个网段读或写,其他的就只能读,然后在发布一个私人目录/home/wds/只开放给192.168.0.8

这个IP

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

现在想要*.chinaunix.com网段的机器登陆我的NFS,并且访问我的/home/wds/ 但是它们存储时我希望它们的uid和gid都变成40这个用户身份

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

/home/wds *.chinaunix.com(rw,all)squash,anounid=40,anongid=40)

如果我们修改/etc/exports这个文件后,是否要从新启动nfs呢?答案是不不需要,只要使用exportfs来从新扫描一次/etc/exports文件,并且从新设置文件加载即可

语法为:

[wds@localhost ~]# exportfs [-aruv]

参数说明:

-a: 全部挂载(或者卸载)/etc/exports 文件的设置

-r: 从新挂载/etc/exports 里设置,此外,同步更新/etc/exports 及/var/lib/nfs/xtab的内容

-u: 卸载某一目录

-v: 在导出时,将共享目录显示在屏幕上

例如:

[wds@localhost ~]# exportfs –rv 全部从新导出一次

[wds@localhost ~]# exportfs –au 全部卸载掉

Showmount 的是显示是否有挂载

语法为:

[wds@localhost ~]# showmount [-ae] hostname

参数说明:

-a: 在屏幕上显示与当前的client连接后使用目录的状态

-e: 显示Hostname这台机器的/etc/exports中的共享信息

[wds@localhost log]# showmount -e localhost

Export list for localhost:

/var/www/html (everyone)

Rpcinfo [-p]hostname[or ip]

-p 显示端口与程序的信息

[wds@localhost log]# rpcinfo -p localhost

program vers proto port

100000 2 tcp 111 portmapper

100000 2 udp 111 portmapper

100024 1 udp 1024 status

100024 1 tcp 1024 status

100011 1 udp 837 rquotad

100011 2 udp 837 rquotad

100011 1 tcp 840 rquotad

100011 2 tcp 840 rquotad

100003 2 udp 2049 nfs

100003 3 udp 2049 nfs

100003 4 udp 2049 nfs

100003 2 tcp 2049 nfs

100003 3 tcp 2049 nfs

100003 4 tcp 2049 nfs

100021 1 udp 1026 nlockmgr

100021 3 udp 1026 nlockmgr

100021 4 udp 1026 nlockmgr

100021 1 tcp 1026 nlockmgr

100021 3 tcp 1026 nlockmgr

100021 4 tcp 1026 nlockmgr

100005 1 udp 858 mountd

100005 1 tcp 861 mountd

100005 2 udp 858 mountd

100005 2 tcp 861 mountd

100005 3 udp 858 mountd

100005 3 tcp 861 mountd

Client端的设置

Server端设置完毕,接下来就是让client端连接上server!连接server步骤如下:

1. 扫描可以使用的server目录:

2. 在client端建立装载点

3. 使用mount 命令远程挂载远程共享目录

4. 解决可能发生的问题(被防火墙过滤掉了)

Showmount是显示远程主机共享资源

[wds@localhost ~]# showmount -e 192.168.0.8

Export list for 192.168.0.8:

/var/www/html (everyone)

/home/wds *.chinaunix.com,192.168.0.6

[wds@localhost ~]# mount -t nfs 192.168.0.8:/var/www/html /mnt 把远程的/var/www/html 挂载到本地

[wds@localhost ~]# umount /mnt 卸载远程目录

如果你想要开机启动时自动加载NFS服务器导出目录,我们在NFS端/etc/fstab文件中加入以下一行

192.168.0.8:/var/www/html /mnt nfs rsize=8192,wsize=8192,timeo=14,intr

Powered by ScribeFire.