红联Linux门户
Linux帮助

windows无法访问RHEL5.5共享?(解决)

发布时间:2010-08-29 18:07:10来源:红联作者:hyf320481
[i=s] 本帖最后由 hyf320481 于 2010-8-29 20:25 编辑 [/i]

我的软件安装好了。。。linux能访问win共享。。。。反过来不行
设置如下
adduser admin
passwd ..
smbpasswd -a admin
xxx xxx
Vi /etc/samba/smb.conf
[cc]
path=/cc
public=yes
writable=yes
防火墙关了。
service smb restart
abc的目录权限777 security=share也没用。。 admin cc 目录都无法访问
这个方法rhel4.0上面没有问题。换了5.5就不行了。

这是过虑# ; 的SMB文件

[global]

workgroup = WORKGROUP
server string = Samba Server Version %v

security = user
passdb backend = tdbsam


load printers = yes
cups options = raw

[homes]
comment = Home Directories
browseable = no
writable = yes

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

[cc]
path = /cc
public = yes
writable = yes
===============================================================

下面是rhel4.0的smb配置文件.
[global]
workgroup = MYGROUP
server string = Samba Server
printcap name = /etc/printcap
load printers = yes

cups options = raw

log file = /var/log/samba/%m.log
max log size = 50
security = user
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

dns proxy = no

idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/false
winbind use default domain = no
[homes]
comment = Home Directories
browseable = no
writable = yes

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
文章评论

共有 4 条评论

  1. nutra 于 2010-08-29 20:37:35发表:

    恭喜啊

  2. hyf320481 于 2010-08-29 20:19:03发表:

    这位兄弟多谢了。。问题解决了。。selinux的问题。。必须关闭才行。关键字:SElinux关闭方式

    关闭SELinux的方法:
    修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
    如果不想重启系统,使用命令setenforce 0
    注:
    setenforce 1 设置SELinux 成为enforcing模式
    setenforce 0 设置SELinux 成为permissive模式
    在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux
    详细出处参考:http://www.itqun.net/content-detail/242970.html

  3. 堕落kiss 于 2010-08-29 19:51:32发表:

    ---------------------------------------------------------------------------------------
    (一)安装SMB
    需要的软件包
    samba-common-3.0.33-3.29.el5_5
    samba-3.0.33-3.29.el5_5
    在centos 5.5光盘中,/CentOS目录下有这2个包,自己找下。
    安装这2个包[code]rpm -ivh samba-3.0.33-3.28.el5.i386.rpm
    rpm -ivh samba-common-3.0.33-3.28.el5.i386.rpm
    [/code]到这个就装完了,非常非常的简单.........
    ---------------------------------------------------------------------------------------
    (二)配置SMB
    在安装完之后,在/etc/下有个samba目录,这个就是配置SMB的目录了 进入这个目录[code]cd /etc/samba/[/code]这个目录下有个smb.conf文件,这个就是SMB的猪文件,先增加samb用户[code]useradd test
    smbpasswd -a test
    [/code]New SMB password: [color=Red]密码
    Retype new SMB password:重复密码
    Added user test.[/color]
    注意:我这里没有用passwd给test用户设置密码,所以这个用户只能SMB的登录,系统无法登录
    现在修改配置文件[code]vi /etc/samba/smb.conf[/code]修改:
    workgroup = WORKGROU //=号右边的就是你要改的名字,改成你的windows组
    下面改共享,回复帖子能看到我把smb.conf关键选项的翻译,虽然我知道翻译的不好,不过我觉得回复可见还是值得的,请讨厌回复可见的人走开一点,我的帖子不欢迎你看,别看了之后就从新发出去,不要让我BS你,请珍惜别人的劳动成果!!
    #============================ Share Definitions ==============================
    我修改的部分都用红色标注
    [homes]
    comment = Home Directories
    browseable = no
    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 Domain Logons
    ; [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 Download
    path = /tmp
    public = yes
    writable = yes
    printable = no
    write list = +test


    到现在已经修改完了配置文件,检查一下有没有问题[code]testparm[/code]Load smb config files from /etc/samba/smb.conf
    Processing section "[homes]"
    Processing section "[printers]"
    WARNING: [printers] service MUST be printable!
    WARNING: No path in service printers - making it unavailable!
    NOTE: Service printers is flagged unavailable.
    Processing section "[public]"
    Loaded services file OK.
    Server role: ROLE_STANDALONE
    Press enter to see a dump of your service definitions
    回车就可以了
    看一下结果有没有问题,我的结果是
    [global]
    server string = Samba Server Version %v
    passdb backend = tdbsam
    cups options = raw

    [homes]
    comment = Home Directories
    read only = No
    browseable = No

    [printers]
    printable = Yes
    browseable = No
    available = No

    [public]
    comment = Public Download
    path = /tmp
    write list = +test
    read only = No
    guest ok = Yes
    [root@localhost samba]#
    说明没有问题 .
    都弄完了,现在该启动服务了.[code]service smb restart[/code]我这里用restart是因为怕以前启动过这个服务,用restart可是保证服务启动和配置文件的更新.
    现在所要做的事情就是等待windows读出这个smb,或者在在开始-->运行,输入\\yourIP,输入用户名的密码.
    ---------------------------------------------------------------------------------------


    下面是配置文件,#开头的是注视,;开头的是选项,以;开头的就是没有生效的选项
    ---------------------------------------------------------------------------------------
    # This is the main Samba configuration file. You should read the
    # smb.conf(5) manual page in order to understand the options listed
    # here. Samba has a huge number of configurable options (perhaps too
    # many!) most of which are not shown in this example
    #
    # For a step to step guide on installing, configuring and using samba,
    # read the Samba-HOWTO-Collection. This may be obtained from:
    # http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
    #
    # Many working examples of smb.conf files can be found in the
    # Samba-Guide which is generated daily and can be downloaded from:
    # http://www.samba.org/samba/docs/Samba-Guide.pdf
    #
    # Any line which starts with a ; (semi-colon) or a # (hash)
    # is a comment and is ignored. In this example we will use a #
    # for commentry and a ; for parts of the config file that you
    # may wish to enable
    #
    # NOTE: Whenever you modify this file you should run the command "testparm"
    # to check that you have not made any basic syntactic errors.
    #
    #---------------
    # SELINUX NOTES:
    #
    # If you want to use the useradd/groupadd family of binaries please run:
    # setsebool -P samba_domain_controller on
    #
    # If you want to share home directories via samba please run:
    # setsebool -P samba_enable_home_dirs on
    #
    # If you create a new directory you want to share you should mark it as
    # "samba-share_t" so that selinux will let you write into it.
    # Make sure not to do that on system directories as they may already have
    # been marked with othe SELinux labels.
    #
    # Use ls -ldZ /path to see which context a directory has
    #
    # Set labels only on directories you created!
    # To set a label use the following: chcon -t samba_share_t /path
    #
    # If you need to share a system created directory you can use one of the
    # following (read-only/read-write):
    # setsebool -P samba_export_all_ro on
    # or
    # setsebool -P samba_export_all_rw on
    #
    # If you want to run scripts (preexec/root prexec/print command/...) please
    # put them into the /var/lib/samba/scripts directory so that smbd will be
    # allowed to run them.
    # Make sure you COPY them and not MOVE them so that the right SELinux context
    # is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
    #
    #--------------
    #
    #======================= Global Settings =====================================

    [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 the hostname
    #
    # 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 = WORKGROUP //这个是工作组的名字
    server string = Samba Server Version %v  //这个大概是描述的意思

    ; netbios name = MYSERVER //你的机子的名字

    ; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 //这个应该是设置网卡的,不确定,知道的告诉我下
    ; hosts allow = 127. 192.168.12. 192.168.13.  //允许访问的ip

    # --------------------------- 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/%m.log //日志文件放的目录
    # max 50KB per log file, then rotate
    ; max log size = 50  //日志文件的大小

    # ----------------------- Standalone Server Options ------------------------
    #
    # Security 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 //这个是安全级别,现在是user认证
    passdb backend = tdbsam //后台认证数据,有3种 tdbsam.smbpasswd,ldapsam在帖子最后,我会发一下这个的资料


    # ----------------------- 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 = //认证服务器的地址

    # ----------------------- 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 the client
    # 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 //SMB成为主
    ; domain logons = yes //98/me把SMB当成域登录服务器

    # the login script name depends on the machine name
    ; logon script = %m.bat //每个工作站特定登录的批处理
    # the login script name depends on the unix user used
    ; logon script = %u.bat //每个用户特定登录的批处理
    ; logon path = \\%L\Profiles\%u//profiles文件存放的位置
    # disables profiles support by specifing 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 on startup
    # and gives it a slightly higher chance of winning the election
    ; local master = no //为no是,SMB不是网络中主Browser
    ; os level = 33 //OS的级别
    ; preferred master = yes //让SMB成为一个局域的Browser

    #----------------------------- 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 WINS Server
    #
    # - 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 //为yes时,smb提供wins
    ; wins server = w.x.y.z //wins 服务器的地址
    ; wins proxy = yes //SMB做为wins代理

    ; dns proxy = yes  //DNS代理

    # --------------------------- 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 to raw
    # 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 = yes //自动载入打印机清单
    cups options = raw

    ; printcap name = /etc/printcap
    #obtain list of printers automatically on SystemV
    ; printcap name = lpstat
    ; printing = cups //使用什么打印系统
    ---------------------------------------------------------------------------------------
    写到这里吧,有点累了,下面的也没有什么好说的了,就是设置共享时候的选项,上面的要是有写的不对的,大家指出,不要讽刺,我也是新手.
    ---------------------------------------------------------------------------------------
    passdb backend就是用户后台的意思。目前有三种后台:smbpasswd、tdbsam和ldapsam。sam应该是security account manager(安全账户管理)的简写。
    1.smbpasswd:该方式是使用smb自己的工具smbpasswd来给系统用户(真实
    用户或者虚拟用户)设置一个Samba密码,客户端就用这个密码来访问Samba的资源。smbpasswd文件默认在/etc/samba目录下,不过有时候要手工建立该文件。
    2.tdbsam:该方式则是使用一个数据库文件来建立用户数据库。数据库文件叫passdb.tdb,默认在/etc/samba目录下。passdb.tdb用户数据库可以使用smbpasswd -a来建立Samba用户,不过要建立的Samba用户必须先是系统用户。我们也可以使用pdbedit命令来建立Samba账户。pdbedit命令的参数很多,我们列出几个主要的。
    pdbedit -a username:新建Samba账户。
    pdbedit -x username:删除Samba账户。
    pdbedit -L:列出Samba用户列表,读取passdb.tdb数据库文件。
    pdbedit -Lv:列出Samba用户列表的详细信息。
    pdbedit -c “[D]” -u username:暂停该Samba用户的账号。
    pdbedit -c “[]” -u username:恢复该Samba用户的账号。
    3.ldapsam:该方式则是基于LDAP的账户管理方式来验证用户。首先要建立LDAP服务,然后设置“passdb backend = ldapsam:ldap://LDAP Server”

    如果配置正确,还是不成,就把SElinux关了

  4. daidaiboy 于 2010-08-29 18:45:10发表:

    贴一个完整的出来,我记得好像是不是有一项,禁止home目录共享的选项来者?