1、安装samba服务,
rpm安装所需包:perl-Convert-ASN1(依赖包)、samba(服务进程)、samba-common(配置文件),samba-client(smb-client客户端)。
2、小案例配置
要求:
a、samb使用user安全级别,创建三个共享目录,/home/samba,/tmp/user1,/tmp/user2;
b、/home/samba的共享名为public,smb用户对其有可读权限,/tmp/user1为user1的共享共享目录,/tmp/user2为user2的共享目录。
a、配置:
#vim /etc/samba/smb.conf
#======================= Global Settings =============
workgroup = MYGROUP
server string = Samba Server Version %v
interfaces = 192.168.2.1/24
bind interfaces only =YES #绑定server监听的ip
hosts allow = 127. 192.168.2. #仅允许127.0.0.0、192.168.2.0网段访问
log file = /var/log/samba/%m.log
#======================= Share Definitions ============
[public]
comment = Public's samba directory
path = /home/samba
public = yes
writable = no
[user1] #共享名
comment = this is user1's samba directory #描述
path = /tmp/user1 #物理路径
public = no
writable = yes #可写
write list = user1 #可写用户
[user2]
comment = this is user1's samba directory
path = /tmp/user2
public = no
writable = yes
valid users = user2 #有效用户
b、创建用户
#useradd user1
#echo "123" | passwd --stdin user1
#useradd user2
#echo "123" | passwd --stdin user2
c、创建目录,并修改所有者
chown user1.user1 /tmp/user1
chown user2.user2 /tmp/user2
echo "test1" > /tmp/user1/user1.txt
echo "test2" > /tmp/user2/user2.txt
测试,
user1不可访问user2的目录,
user2可以访问user1的目录,但仅有读取权限,和执行权限