天天看點

llinux企業常用服務---samba共享

一、samba匿名共享搭建:

mount /dev/cdrom /mnt

vi /etc/yum.repos.d/rhel.repo

[local]

name=lcoal

baseurl=file:///mnt

enabled=1

gpgcheck=0

:wq

關閉selinux

yum -y install samba

vi  /etc/samba/smb.conf   ##修改主配置檔案

##删除注釋:%g /^#/d  删除空行:%g /^$/d  删除樣例行:%g /^;/d  删除多餘空行;修改如下:

[global]

        workgroup = MYGROUP

        server string = Samba Server Version %v

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

        max log size = 50

        security = share

        passdb backend = tdbsam

        load printers = yes

        cups options = raw

[public]

        comment = Public Stuff

        path = /opt/share

        public = yes

        writable = yes

        printable = no

mkdir  /opt/share

touch /opt/share/a.file

chmod 777 /opt/share

testparm   ##測試配置是否有誤

/etc/init.d/smb  start

chkconfig smb on

netstat -utpln |grep mb  ##TCP:139,445/UDP:137,138檢視端口

防火牆配置:

iptables -I INPUT -m multiport -p tcp --dports 22,139,445 -j ACCEPT

iptables -I INPUT -m multiport -p udp --dports 137,138 -j ACCEPT

iptables -P INPUT DROP

iptables -P FORWARD DROP

iptables -I INPUT -m state --state ESTABLISHED -j ACCEPT

iptables -I INPUT -i lo -j ACCEPT

/etc/init.d/iptables save

測試:

windows:

\\ip位址\public

二、samba使用者認證的共享:注意匿名和認證選一個

建立使用者:

useradd u01

useradd u02

pdbedit -a u01  ##将系統使用者添加為smb使用者

pdbedit -a u02

pdbedit -L  ##檢視smb使用者

修改配置檔案:

[root@smb ~]# vi /etc/samba/smb.conf

        security = user    ##使用者認證的共享

        public = no   ##共享非公開

        writable = no   ##預設不可以寫

        valid users = u01, u02  ##允許通路的使用者

        write list = u01  ##有寫入權限的使用者

testparm

/etc/init.d/smb  restart

繼續閱讀