Samba服务器配置 (REDHAT6.4)

来源:互联网 发布:php在线编辑器源代码 编辑:程序博客网 时间:2024/06/13 11:06
一:保证网络连通性


[root@li ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0C:C3:1F  
          inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0c:c31f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3313 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3002 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1886136 (1.7 MiB)  TX bytes:1702104 (1.6 MiB)
          Interrupt:18 Base address:0x2000 


[root@li ~]# service iptables stop        //关闭防火墙
[root@li ~]# chkconfig iptables off 
[root@li ~]# setenforce 0


二 安装samba服务器软件包组(本地YUM源方式安装)


[root@li ~]# mkdir /ww                     //创建文件夹
[root@li ~]# mount /dev/cdrom /ww/         //挂载光盘
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@li ~]# cd /etc/yum.repos.d/
[root@li yum.repos.d]# ls
rhel-source.repo                             //编辑这个配置文件  


[root@li yum.repos.d]# vi rhel-source.repo 
[rhel-source] 
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///ww/                          //YUM仓库文件的路径
enabled=1                                    //启用gpg校验值验证
gpgcheck=1                                   //将此处的0改为1,表明启用本地YUM源安装
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  
[root@li yum.repos.d]# yum -y install samba   //安装samba


三:构建可匿名访问的共享


[root@li ~]# cd /etc/samba
[root@li samba]# ls
lmhosts  smb.conf  smbusers
[root@li samba]# vi smb.conf                   //修改主配置文件
...
    101         security = share               //将user改为share 启用匿名共享
...
    289        [benet]
    290        comment = benetbenet
    291        path = /pp/
    292        public = yes
    293        writable = yes
...


[root@li samba]# chmod 777 /pp/              //给共享的文件夹系统权限777


[root@li samba]# testparm                    //测试配置文件的正确性
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
WARNING: The security=share option is deprecated
Loaded services file OK.                     //出现此行表明配置文件没有错误


[root@li samba]# service smb start           //启动samba服务器
启动 SMB 服务:                                            [确定]
[root@li samba]# service nmb start
启动 NMB 服务:                                            [确定]


---重要-----
/etc/selinux/config 
将SELINUX=enforcing改为SELINUX=disabled
--开机自动重启
chkconfig --level 35 nmb on
chkconfig --level 35 smb on
//关闭防火墙
service iptables stop         
chkconfig iptables off 


-----------
测试---
 




四:构建需用户验证的共享


建立samba用户
[root@li ~]# useradd li                  // 建立samba用户
[root@li ~]# pdbedit -a -u li
new password:
retype new password:


[root@li ~]# mkdir /opt/mytools       //创建本地测试目录
[root@li ~]# chmod 777 /opt/mytools/


[root@li ~]# vi /etc/samba/smb.conf   
              security = user        将share改为user   表示启用USER安全级别


在最后一行输入
 [tools]
        comment = You can get software tools from here.
        path = /opt/mytools
        public = no
        read only = yes
        valid users = li
        write list = hunter




测试-------------
 
 

0 0
原创粉丝点击