标签:mod 设置 install map detail 操作 path use after
配置用户共享用户服务端IP | 客户端IP |
---|---|
192.168.24.248 | 192.168.24.145 |
关闭防火墙和selinux
[root@linfan ~]systemctl disable firewalld
[root@linfan ~]systemctl stop firewalld
[root@linfan ~]sed -ri ‘#^SELINUX=#cSELINUX=Disabled‘ /etc/selinux/config
[root@linfan ~]setenforce 0
yum -y install samba-*
useradd -M lin
为用户lin创建smb共享密码
smbpasswd -a lin
将lin用户映射为share用户:
echo ‘lin = share‘ > /etc/samba/smbusers
在全局变量中添加如下内容:
[root@linfan ~]# vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run ‘testparm‘ to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
username = /etc/samba/smbusers //在此添加
[root@linfan ~]# mkdir -p /opt/lin/
[root@linfan ~]# chown -R lin.lin /opt/lin/
[root@linfan ~]# cat >> /etc/samba/smb.conf <<EOF
> [lin]
> comment = lin
> path = /opt/lin
> browseable = yes
> guest ok = yes
> writable = yes
> write list = share
> public = yes
> EOF
[root@linfan ~]# tail -8 /etc/samba/smb.conf
[lin]
comment = lin
path = /opt/lin
browseable = yes
guest ok = yes
writable = yes
write list = share
public = yes
启动smb服务
[root@linfan ~]# systemctl start smb
重启smb服务
[root@linfan ~]# systemctl restart smb
重新加载smb服务
[root@linfan ~]# systemctl reload smb
设置smb开机自启动
[root@linfan ~]# systemctl enable smb
[root@linfan ~]# smbclient -L 192.168.24.248 -U share
[root@linfan ~]# mkdir -p /opt/smb/
[root@linfan ~]# mount -t cifs //192.168.24.248/lin /opt/smb -o username=share,password=1
[root@linfan ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 6.0G 12G 35% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.9M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 1014M 125M 890M 13% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /mnt
//192.168.24.248/lin 17G 6.0G 12G 36% /opt/smb
[root@linfan opt]# cd /opt/smb
[root@linfan smb]# mkdir l
[root@linfan smb]# touch k
[root@linfan smb]# ls
k l
[root@linfan ~]# cd /opt/lin
[root@linfan lin]# ls
k l
服务端IP | 客户端IP |
---|---|
192.168.24.248 | 192.168.24.146 |
关闭防火墙和selinux
[root@linfan ~]systemctl disable firewalld
[root@linfan ~]systemctl stop firewalld
[root@linfan ~]sed -ri ‘#^SELINUX=#cSELINUX=Disabled‘ /etc/selinux/config
[root@linfan ~]setenforce 0
[root@linfan ~]# yum -y install samba-*
[root@linfan ~]# vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run ‘testparm‘ to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
map to guest = Bad User //在此添加
[root@linfan ~]# mkdir /opt/doudou
[root@linfan ~]# chmod 777 /opt/doudou
[root@linfan ~]# ll /opt/
total 0
drwxrwxrwx. 2 root root 6 Aug 6 19:08 doudou
drwxr-xr-x. 8 root root 220 Jul 18 17:09 lin.d
[root@linfan ~]# cat >> /etc/samba/smb.conf <<EOF
> [doudou]
> comment = doudou
> path = /opt/doudou
> browseable = yes
> guest ok = yes
> writable = yes
> public = yes
> EOF
[root@linfan ~]# tail -7 /etc/samba/smb.conf
[doudou]
comment = doudou
path = /opt/doudou
browseable = yes
guest ok = yes
writable = yes
public = yes
[root@linfan ~]# systemctl start smb
[root@linfan ~]# smbclient -L 192.168.24.248 -U‘Bad User‘
[root@linfan ~]# mkdir -p /opt/smb
[root@linfan ~]# mount -t cifs //192.168.24.248/doudou /opt/smb -o username=‘Bad User‘
[root@linfan ~]# df -h
[root@linfan ~]# cd /opt/smb
[root@linfan smb]# mkdir lin
[root@linfan smb]# touch wu
[root@linfan smb]# ls
lin wu
[root@linfan doudou]# ls
lin wu
标签:mod 设置 install map detail 操作 path use after
原文地址:http://blog.51cto.com/13858192/2155437