【linux基礎】samba匿名共享+用戶認證共享
一、匿名共享
1、安裝
yum -y install samba* ##安裝samba軟件
2、修改配置文件
vi /etc/samba/smb.conf
[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
:wq
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查看端口
3、測試:
windows:
\\10.10.10.95\public
linux:
mount //10.10.10.95/public /mnt
用戶認證的共享:註意匿名和認證選一個
二、用戶認證共享
1.創建用戶:
useradd user01
useradd user02
pdbedit -a user01 ##將系統用戶添加為smb用戶
pdbedit -a user02
pdbedit -L ##查看smb用戶
2.修改配置文件:
[[email protected] ~]# vi /etc/samba/smb.conf
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user ##用戶認證的共享
passdb backend = tdbsam
load printers = yes
cups options = raw
[public]
comment = Public Stuff
path = /opt/share
public = no ##共享非公開
writable = no ##默認不可以寫
valid users = user01, user02 ##允許訪問的用戶
write list = user01 ##有寫入權限的用戶
:wq
testparm
/etc/init.d/smb restart
netstat -utpln |grep mb
3.測試:
linux:客戶機
mount -o username=u01 //10.10.10.95/public /mnt
cd /mnt
touch b.file
ls
windows:
\\10.10.10.95\public
【linux基礎】samba匿名共享+用戶認證共享