本文的目的主要用来说明如何在CentOS6.5的环境下配置出一个简单可用的samba服务,并且可以通过windows对其文件进行访问 安装相关软件# yum install samba samba-client samba-commo<span class="com"># chkconfig smb on</span><span class="com"># chkconfig nmb on</span><span class="com"></span> 对路由表做如下操作# iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT# iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT# iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT# service iptables save备份配置文件在正式配置之前,对配置文件进行备份 # cp /etc/samba/smb.conf /etc/samba/smb.conf.bak# rm /etc/samba/smb.conf# touch /etc/samba/smb.conf# vi /etc/samba/smb.conf配置一个公开的目录配置一个公开的访问目录,在新创建的smb.conf文件中加入以下配置<pre name="code" class="plain">#======================= Global Settings =====================================[global]workgroup = WORKGROUPsecurity = sharemap to guest = bad user#============================ Share Definitions ==============================[MyShare]path = /home/samba/sharebrowsable =yeswritable = yesguest ok = yesread only = no设置文件夹权限,检测配置文件,重启服务<pre style="" class="wp-code-highlight prettyprint linenums:1 prettyprinted"><span class="com"># chmod -R 0777 /home/samba/share</span><pre style="" class="wp-code-highlight prettyprint linenums:1 prettyprinted"><span class="com"># testparm</span># service smb restart# service nmb restart配置一个受限的访问目录添加相关的操作员以及组配置<pre name="code" class="plain"> # useradd smbuser # groupadd smbgrp # usermod -a -G smbgrp smbuser # smbpasswd -a smbuser创建一个需要特殊用户才能访问的目录 # cd /home/samba/ # mkdir secure # chown -R arbab:smbgrp secure/ # chmod -R 0770 secure/在配置文件中加入下面的配置[Secure]path = /home/samba/securevalid users = @smbgrpguest ok = nowritable = yesbrowsable = yes检测配置文件,重启服务 # testparm # service smb restart # service nmb restart解决没有权限访问的问题<p> 如果出现无权限访问的问题,可以通过关闭防火墙以及selinux来尝试</p><pre name="code" class="plain"> # service iptables stop # setenforce 0
|