Linux SAMBA服务器配置共享目录,访问控制,用户映射
[global]# ----------------------- Network Related Options-------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to thehostname
#
# Interfaces lets you configure Samba to use multiple interfaces
# If you have multiple network interfaces then you can list the ones
# you want to listen on (never omit localhost)
#
# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
# specifiy it as a per share option as well
#
workgroup = MYGROUP
server string = Samba Server Version%v
; netbios name = MYSERVER
interfaces = lo eth0
hosts allow = 192.168.1.
user map =/etc/samba/smbusermap
# --------------------------- Logging Options-----------------------------
#
# Log File let you specify where to put logs and how to split them up.
#
# Max Log Size let you specify the max size log files should reach
# logs split per machine
log file = /var/log/samba/log.%m
# max 50KB per log file, thenrotate
max log size = 50
# ----------------------- Standalone Server Options------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
security = user
passdb backend = tdbsam
# ----------------------- Domain Members Options ------------------------
#
# Security must be set to domain or ads
#
# Use the realm option only with security = ads
# Specifies the Active Directory realm the host is part of
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# Use password server option only with security = server or if you can\'t
# use the DNS to locate Domain Controllers
# The argument list may include:
# password server = My_PDC_Name[My_BDC_Name] [My_Next_BDC_Name]
# or to auto-locate the domain controller/s
# password server = *
; security = domain
; passdb backend = tdbsam
; realm = MY_REALM
; password server =NT-Server-Name
# ----------------------- Domain Controller Options------------------------
#
# Security must be set to user for domain controllers
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# 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 Logons let Samba be a domain logon server for Windows workstations.
#
# Logon Scrpit let yuou specify a script to be run at login time on theclient
# You need to provide it in a share called NETLOGON
#
# Logon Path let you specify where user profiles are stored (UNC path)
#
# Various scripts can be used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
#
; security = user
; passdb backend = tdbsam
; domain master = yes
; domain logons = yes
# the login script name depends on themachine name
; logon script = %m.bat
# the login script name depends on theunix user used
; logon script = %u.bat
; logon path = \\\\%L\\Profiles\\%u
# disables profiles support byspecifing an empty path
; logon path =
; add user script = /usr/sbin/useradd\"%u\" -n -g users
; add group script = /usr/sbin/groupadd\"%g\"
; add machine script = /usr/sbin/useradd-n -c \"Workstation (%u)\" -M -d /nohome -s /bin/false\"%u\"
; delete user script = /usr/sbin/userdel\"%u\"
; delete user from group script =/usr/sbin/userdel \"%u\" \"%g\"
; delete group script =/usr/sbin/groupdel \"%g\"
# ----------------------- 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
#
# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
#
# Preferred Master causes Samba to force a local browser election onstartup
# and gives it a slightly higher chance of winning the election
; local master = no
; os level = 33
; preferred master = yes
#----------------------------- Name Resolution -------------------------------
# Windows Internet Name Serving Support Section:
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
#
# - WINS Support: Tells the NMBD component of Samba to enable it\'s WINSServer
#
# - WINS Server: Tells the NMBD components of Samba to be a WINS Client
#
# - 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.
#
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups.
; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes
; dns proxy = yes
# --------------------------- Printing Options-----------------------------
#
# Load Printers let you load automatically the list of printers rather
# than setting them up individually
#
# Cups Options let you pass the cups libs custom options, setting it toraw
# for example will let you use drivers on your Windows clients
#
# Printcap Name let you specify an alternative printcap file
#
# You can choose a non default printing system using the Printing option
load printers = no
cups options = raw
; printcap name = /etc/printcap
#obtain list of printers automaticallyon SystemV
; printcap name = lpstat
; printing = cups
# --------------------------- Filesystem Options---------------------------
#
# The following options can be uncommented if the filesystem supports
# Extended Attributes and they are enabled (usually by the mount option
# user_xattr). Thess options will let the admin store the DOS attributes
# in an EA and make samba not mess with the permission bits.
#
# Note: these options can also be set just per share, setting them inglobal
# makes them the default for all shares
; map archive = no
; map hidden = no
; map read only = no
; map system = no
; store dos attributes = yes
#============================ Share Definitions==============================
[homes]comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\\%S
[sales]comment = Home Directories
path=/var/samba/sales
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\\%S
[finance]comment = Home Directories
browseable = yes
path=/var/samba/finance
writable = yes
; valid users = %S
; valid users = MYDOMAIN\\%S
[printers]comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
# Un-comment the following and create the netlogon directory for DomainLogons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; 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 = /var/lib/samba/profiles
; browseable = no
; guest ok = yes
# A publicly accessible directory, but read only, except for people in
# the \"staff\" group
; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff
以上是smb.conf内的配置。
增加用户和组,并设置好用户组的隶属关系。
用smbpasswd -a 增加smb访问密码。
linux下用samba配置资源共享服务器
对不起啦。分给楼上的吧,我不要了,本来这个东西也不是我写的,楼上的人能自己操作,说明技术比我好多了。
,,,
这个问题不用测试了,已经有高手写出了具体的做法。
这个是这个教程里设计的,估计完全可以达到你的要求!
/linuxsir (注:Samba文件系统中共享目录名)
|
|———/管理部 (管理部成员的家目录)
| |_______/sirmas01 (注:管理成员sirmas01的家目录sirmas01)
| |_______/sirmas02 (注:管理成员sirmas0202的家目录sirmas02)
|
|——— /software (注:软件共享目录,只有管理部成员或更高权限的管理员能管理)
|
|——— /公共文档 (注:所有用户都能查看的文档,只有管理部用户sirmas01和sirmas02有写入权限,进行文档管理)
|——— /共享可写 (注:所有用户都能在此目录下写入文件,sir03或sir04用户可以进行管理,或文件服务器管理员权限用户进行管理)
|——— /成员 (注:公司员工的家目录存放地,每个成员在此目录下都有自己的家目录)
|————|_______/sir03 (注:sir03用户的家目录)
|————|_______/sir04 (注:sir04用户的家目录)
linux中简述wed服务器配置过程
浅谈基于Linux的Intranet环境建造
在建设传统的Intranet网络环境的时候,我们一般是基于Windows NT Server系统的,在它的基础上实现一系列的服务。 现在的Linux系统中也包含了很多基于网络建设的软件服务,基本上我们是完全可以利用Linux系统建立与Windows NT Server所具有的基本Intranet框架相同的框架。并且还可以在这个基础上发展具有Linux系统自身特点的Intranet环境,在某种程度上其性能还优于Windows NT Server系统。
我们先假设一个基于Linux系统局域网的网络构架。首先,建议使用转换器把Internet接口转换为双绞线,直接连接到一台双网卡Server上。该Server的另外一块网卡和其他的Server及Client连接到一个Hub上面,成为一个局域网。双网卡的服务器作为防火墙和网关,控制内部网和Internet连接的安全。我们在其上面还可以运行其他的服务,例如文件服务器、代理服务器、邮件服务器和Web服务器等。另外一台服务器可以作为数据库服务器,在其上主要运行数据库服务。
双网卡中对外的网卡必须有正式的IP,另外一块网卡和其他计算机的网卡可以使用私有IP,范围从“192.168.1~192.168.254”自由分配,其他计算机的网关地址都指向防火墙网关服务器的内部IP。防火墙网关服务器的网络配置要根据申请的IP地址来具体设置。
一般地,我们要求的Intranet环境应该是提供最基础的WWW服务、FTP服务、DNS服务、网上邻居等服务项,下面我们就一一简单地介绍一下。
1.WWW服务
首先我们要实现WWW服务,我们以在RedHat系统的完全安装中为例,这里系统已经为大家安装好了目前在Internet上使用得最多的HTTP服务器Apache, 你只需要使用“setup”命令选择该服务,或者直接运行“httpd”即可。它的安装根目录是在/home/httpd/目录下的,只要使用浏览器按照“IP地址”访问你的Web server,就能够看到Apache的说明文档。如果你要发行自己的主页,只需要将这些文档放在/home/httpd/Html/下即可,或者是将httpd.conf中的文档根目录修改为你的Windows系统下的目录,这样既可以享受Linux的效率,也可享受Windows的页面制作工具的便利。但是我们要注意在Linux环境中要区分大小写,所以页面中的文件名最好统一使用大小写。在Windows环境中的页面文件一般是.htm后缀,而缺省的Linux系统的浏览器Netscap或lyxn解释的页面文件是以.html为后缀的,你只需要在/etc/mime.types中增加如下一行即可:text/html html htm。同样,你也可以按照注释修改以下配置文件:
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/Access.conf
/etc/httpd/conf/srm.conf 以建立更加强大而灵活的WEB服务器。
2.FTP服务
接着让我们看看FTP服务的实现,我们依然是在RedHat系统的完全安装中,RedHat系统已经为你安装好了目前Internet流行的WU-FTP-2.4.2 Server。它的匿名访问目录在/home/ftpd/中,如果是在FTP客户端使用普通帐户登录,那么我们将直接进入该账户的主目录。它的配置文件主要是:
/ect/ftpaccess。
域名服务(DNS服务)的功能是把我们取的名字映射为具体的IP地址。目前Internet流行的域名服务器BIND,它的执行进程是“named”,其配置文件有:
/ect/named.conf
/etc/resolv.conf
/var/named/named.ca
/var/named/named.local
/var/named/named.hosts(自建)
/var/named/named.rev
其中的自建文件需要符合“named”配置文件的格式,我们从已有的文件中cp即可,尤其注意BIND 4的配置文件格式和BIND 8p是完全不同的,如果使用的版本不同的话,请查阅其具体的配置文件。
3.RAS服务
RAS服务(PPP)也是传统的服务之一,配置PPP在Linux系统中是比较复杂的一项工作。它的主要配置文件有:
/etc/mgetty+sendfax/mgetty.config
/etc/mgetty+sendfax/loging.config
/etc/inittab
/etc/ppp/options
/etc/ppp/ppplogin
/etc/ppp/options.ttyS2
/etc/ppp/pap-secrets
/etc/hosts
提醒大家的是如果使用Win95的拨号适配器的话,它的网关为拨号服务器的IP,DNS为内部网的DNS Server的IP,设置远程自动配置IP,新手可以先不启动该服务。
4.DHCP功能
DHCP的功能是动态分配IP地址。注意在启动dhcpd之前,增加一项缺省路由:/sbin/route add -host 255.255.255.255 dev eth0详细的格式可以使用“main dhcpd”得到。它的执行进程是“dhcpd”,它的配置文件有:
/etc/dhcpd.conf /etc/dhcpd.leases(空文件)
/etc/dhcpd.leases~(空文件夹)
5.网上邻居
网上邻居(smbd nmbd)也是我们很关心的功能,微软的网上邻居是局域内直接而简便的资源共享方法,但它采用的是Netbeui协议。而Linux系统采用的主要是TCP/IP协议,它提供的Samba可以方便地完成网上邻居的功能,让你的用户通过网上邻居看到你的服务器和共享的资源。其主要配置文件有:
/etc/smb.conf
/etc/smbusers
代理服务和防火墙(routed lpmasquerdde ipfwadm)的设置对于一些用户也是必要的。在Windows NT中也有“routed”命令,但要实现共享IP地址却要使用专门的代理软件,如proxy Server、 Wingate、Winproxy等。在这方面,Linux利用核心支持的“ipmasquerad”功能,配合“routet”和“ipfwadm”则可以轻松地实现这一功能,并且在使用浏览器时还不需要指定代理服务器,同时利用“ipfwadm”确定接收和发送数据包的规则,并且还可以提供基于包过滤的防火墙设施。它的主要配置命令有:
/sbin/ipfwadm -F -P deny
/sbin/ipfwadm -F -a m -s 192.168.0.0/16 -D 0.0.0.0/0
/sbin/route add -net 192.168.0.0 netmask 255.255.255.0 gw 130.0.40.1
6.SQL数据库系统
SQL数据库系统(postgresql)在目前的Intranet环境中是越来越重要了,但在Windows NT平台上运行的商品化的SQL数据库价格不菲。Linux系统集成的SQL数据库主要有Postgre和SQLmysql,它们均达到了SQL92的标准,并且提供在 Windows系统的客户端的ODBC驱动程序,是非常理想的后端数据库系统。PostgreSQL是普遍使用的免费SQL数据库系统之一,而且是一些商用SQL数据库的原形。尽管它可能没有现在的某些商品化SQL功能强大,并且能够处理中文,作为一般的Intranet Web数据库系统,使用它已经是绰绰有余了。它还为编制CGI程序提供了方便的接口。要访问postgreSQL可使用命令“psql”,缺省的管理员账号“postgres”是在安装后禁用的,需要给予登录权限。为了让Web客户能够访问数据库,我们需要给“nobody”用户授权。
微软的ASP技术作为IIS的模块,可以简化CGI程序的编制,提高Web服务器的效率,提供灵活的数据库连接方法。Linux系统中的Apache也有相应的PHP模块,由于Linux系统中包含有使用最广泛的CGI编程语言PERL 5,所以我们可以轻松而高效地设计CGI程序。
7.其他实现
Linux系统里还有一些对构建Intranet环境比较有用的东西,比如磁盘限额(quota)服务,使用限额机制可以控制用户对资源的拥有量,防止非法上载,是多用户环境下必须具备的功能。我们还是以RedHat为例,RedHat中启动磁盘限额方法很简单,只需要使用Linuxconf中的相应选项即可。但是你需要在实施限额的文件系统的根目录下建立“quota.user”和“quota.group”两个空文件,并且,应该在安装完系统后立即启动该服务,linuxconf程序不光可以动态配置系统,而且具有多种工作界面,极大地方便了用户配置与管理系统。为了能够运行linuxconf,我们必须以根(root)用户的身份登录Linux系统。如果你不是以根用户的身份登录系统,那么可在系统提示符下执行“su”命令,变成根用户。常见的linuxconf工作界面有:命令行界面、字符单元界面(使用了像RedHat Linux安装时的用户界面形式)、基于XWindow的界面(提供易于使用的“点击”树状菜单)。
我们以RedHat Linux 6.0系统为例,想要linuxconf在Web浏览器环境工作,必须进行以下设置:
* 在gnome-linuxconf对话框中,打开“Config/Networking/Misc/Linuxconf network access”分支,选中“Enable netwoork access”选项。
* 在对话框中输入任何允许使用Linuxconf的计算机的主机名,包括用户主机名字。
* 选择“Accept”按钮,并按空格键,单击“Quit”按钮。
* 启动Netscape浏览器,在URL栏键入:http://〈hostname〉:98/ 〈cr〉。其中,必选项“hostname”应换成用户计算机的主机名。
* 选择浏览器页面底部的“Start”按钮,在弹出的口令验证框中,分别输入根用户的名字“root”和相应的口令。如果口令正确,则进入基于Web的linuxconf工作界面。该界面主要由Config和Control两部分组成,它们各自均含有5个具有超链接特性的选项,用户单击具体的选项,即可打开对应的页面,完成相应的配置。
Linux系统中包含的“sendmail”是Internet电子邮件系统中主要的SMTP软件,“imapd”软件是POP3邮件服务器,可以让你使用Netscape或IE轻松收发电子邮件。注意,你要在/etc/sendmail.cw中添加内部域名,再将/etc/sendmail.cf中的F项修改为Fw/etc/sendmail.cw.远程登录(Telnet)。
现在有很多的关于Linux系统方方面面的文章,所以如果是要建立一个基于Linux系统的Intranet环境,还有很多的参考,而且要是想让你的Intranet环境完美起来,还有很多的服务等你实现。
(出处:)
怎样在Linux系统搭建Samba共享服务器
Linux系统默认已经安装了Samba,但是没有安装Samba服务:
1,先查看安装情况:rpm -qa|grep samba
根据系统的安装情况选择下载或者通过光驱安装所缺的rpm包。
我的安装情况是:
使用命令:mount /dev/cdrom1 /mnt/cdrom1
通过mount把cdrom1挂载到系统临时目录/mnt/cdrom1,在Packets包下面使用命令:rpm -ivh
samba.*.rpm包安装。
切换到放置rpm文件的目录
[root@smb_server root]# rpm-ivh samba-common-3.6.9-151.el6.x86_64
这是Samba 必备的程序,必须安装
[root@smb_server root]# rpm-ivh samba-3.6.9-151.el6.x86_64
安装Samba 服务器程序,可以使我Windows 主机访问Samba 服务器共享的资源。
如果需要使Linux 主机访问Windows 主机上的共享资源,则还应该安装Samba 客户端程序。
[root@smb_server root]# rpm-ivh samba-client-3.6.9-151.el6.x86_64
2,安装samba的rpm包完成后
samba-common-3.6.9-151.el6.x86_64
//主要提供samba服务器的设置文件与设置文件语法检验程序testparm
samba-client-3.6.9-151.el6.x86_64
//客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集
samba-swat-3.6.9-151.el6.x86_64
//基于https协议的samba服务器web配置界面
samba-3.6.9-151.el6.x86_64
//服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项
Samba服务器安装完毕,会生成配置文件目录/etc/samba和其它一些samba可执行命令工具,/etc/samba/smb.conf是samba的核心配置文件,/etc/init.d/smb是samba的启动/关闭文件。
5、查看samba的服务启动情况
# service smb status
6、设置开机自启动
# chkconfig --level 35 smb on //在3、5级别上自动运行samba服务
7、配置smb服务
[global]workgroup = WORKGROUP
server string = Samba Server Version %v
netbios name = ImgPath05
[ImgPath]comment = Public stuff
path =
/usr/local/nginx/html/img
public = yes
writeable = yes
browseable =
yes
guest ok = yes
共享目录为:/usr/local/nginx/html/img,共享目录对外名称为:ImgPath 即在Windows看到的目录名称。
设置共享目录权限:chown -R nobody:nobody /usr/local/nginx/html/img/
8、启动或者重启smb服务
重启smb服务
测试smb.conf配置是否正确
9 Windows访问共享目录,但是没有写权限,通过以下方式修改防火墙设置。
将Linux smb服务添加到防火墙的例外中
以root用户执行setup命令#setup弹出...重启生效,如果不想重启,用命令#setenforce 0