6 yum install samba-client.x86_64 -y /下载
7 yum install samba.x86_64 -y
8 yum install samba-common.x86_64 -y
9 systemctl start smb
10 netstat -antlupe | grep smb
11 systemctl status smb
12 ls
15 firewall-cmd --list-all
16 firewall-cmd --permanent --add-service=samba
17 firewall-cmd --permanent --add-service=samba-client
19 firewall-cmd --reload
21 pdbedit -L
22 useradd westos
23 useradd lee
24 snbpasswd -a westos
25 smbpasswd -a westos
26 smbpasswd -a lee
27 smbpasswd -a lee1
28 pdbedit -L
29 ifconfig eth0
30 cd /home/westos/
31 touch {1…10}
在测试端
177 yum install samba-client.x86_64
178 smbclient -L //172.25.254.59
179 smbclient -L //172.25.254.59 -U westos
180 smbclient -L //172.25.254.59/westos -U westos
181 cd /home/westos
182 cd /home/
183 ls
184 smbclient -L //172.25.254.59/westos -U westos
185 smbclient //172.25.254.59/westos -U westos
186 mkdir 1
187 smbclient //172.25.254.59/westos -U westos
188 touch 1
189 touch 111
191 ifconfig n
192 ifconfig
194 smbclient //172.25.254.110/westos -U westos
197 history
199 smbclient //172.25.254.59/westos -U lee
201 mount //172.25.254.59/westos /mnt -o username=westos,password=westos
vim /etc/sysconf/selinux
122 mkdir /westos_smb /创建要共享的文件夹
123 chmod 777 /westos_smb/ /给予权限因为他是root用户创建要共享就要使用其他用户没有权限其他用户无法操作
124 semanage fcontext -a -t samba_share_t ‘/westos_smb(/.*?)?’ /修改文件夹的安全上下文
125 restorecon -RvvF /westos_smb/ /生效安全上下文
vim /etc/sambasmb.conf /进入配置文件
321 [niuhao] /添加以下
322 comment = hahahahah
323 path = /westos_smb
324 writable = yes
vim /etc/samba/smb.conf /添加以下内容
[mnt]
comment =niuahosh
path = /mnt
writable = yes
systemctl restart smb /重起服务
etfacl -m u:westos:rwx /mnt / 开启权限列表授权给wetos用户/mnt的全部权限
getsebool -a | qrep samba /查看selinux中噶关于samba的设置
setsebool -P samba_export_all_rw on /关闭selinux对于samba共享文件的安全上下文,解除限制
客户端
umount /mnt
mount //172.25.254.109/mnt /mnt -o username=westos,password=westos有开放sabma文件夹的写权限是无法挂载的
当只打开sabma的读权限无论是客户端还是服务端都无法在/mnt这个文件夹下创建和删除
服务端
vim /etc/samba/smb.c
1、是否允许浏览:browseable = yes|no
2、是否可写:writable = yes|no
3、允许用户列表:write list = @student
4、允许组列表(+或@表示组):write list = +student
5、指定超级用户,在可写情况下才可以执行动作:admin users = westos
6、描述:comment =
7、本地共享目录:path =
在客户端挂载使用超级用户
yum install cifs-utils.x86_64 -y /安装服务
man mount.cifs /查看帮助
vim /root/snbpasword /创建一个文件储存用户密码
chmod 600 /root/snbpaswo /设置权限仅超级用户可以读写
man mount.cif
man mount.cifs
vim /root/snbpasword
chmod 600 /root/snbpasword
mount //172.25.254.109/niuhao /mnt -o credentials=/root/snbpasword
df
umount /mnt/
mount //172.25.254.109/niuhao /mnt -o credentials=/root/snbpasword,sec=ntlmssp
umount /mnt/
mount //172.25.254.109/niuhao /mnt -ocredentials=/root/snbpasword,sec=ntlmssp,multiuser
umount /mnt/
使用普通用户
cifscreds add -u lee 172.25.254.109
password: /输入lee密码
cd /mnt /进入目录
ls /查看成功