标签:ip地址 ddd 挂载点 txt star file reload user rom
1.应用场景,搭建sam共享目录2.服务端ip:192.168.56.11 (A)
客户端ip:192.168.56.133 (B)
查看防火墙状态并关闭
[root@guohui ~]#systemctl status firewalld
[root@guohui ~]#systemctl disable firewalld
[root@guohui ~]#systemctl stop firewalld
[root@guohui ~]#setenforce 0
先安装sam,并设置sam用户
[root@guohui ~]# yum -y install samba-*
[root@guohui ~]# useradd -M DDD //创建用户DDD,-M,不建立用户家目录
[root@guohui ~]# smbpasswd -a DDD //添加系统用户为samba用户并设置密码123
New SMB password:
Retype new SMB password:
Added user DDD.
testparm
[root@guohui samba]# touch smbusers //在 /etc/samba下创建/smbusers
[root@guohui samba]# echo ‘DDD = share‘ > /etc/samba/smbusers //这里要将映射DDD为share用户,需在/etc/samba/smbusers 文件中添加 DDD = share
[root@guohui samba]# vim /etc/samba/smb.conf //在全局配置中添加如下
[global]
workgroup = SAMBA
security = user
username map = /etc/samba/smbusers //添加用户名映射文件 /etc/samba/smbusers
[root@guohui ~]# mkdir /opt/guohui
[root@guohui ~]# chown -R DDD.DDD /opt/guohui
[root@guohui ~]# testparm //测试配置文件是否有语法错误,查看最终生效的配置
Load smb config files from /etc/samba/smb.conf
[root@guohui ~]# ll /opt/
总用量 0
drwxr-xr-x. 2 DDD DDD 6 8月 6 17:07 guohui
//配置共享
[root@guohui ~]# cat >> /etc/samba/smb.conf <<EOF
> [guohui]
> comment = guohui
> path = /opt/guohui
> browseable = yes
> guest ok = yes
> writable = yes
> write list = share
> public = yes
> EOF
[root@guohui ~]# tail -8 /etc/samba/smb.conf
[guohui]
comment = guohui
path = /opt/guohui
browseable = yes
guest ok = yes
writable = yes
write list = share
public = yes
[root@guohui ~]# systemctl start smb //启动smb服务
[root@guohui ~]# systemctl restart smb //重启smb服务
[root@guohui ~]# systemctl reload smb //重新加载smb服务
[root@guohui ~]# systemctl enable smb //设置smb服务随系统启动而启动
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
//在客户机查看samba服务器有那些共享资源 (B)
[root@guohui ~]# smbclient -L 192.168.56.11 -U share
Enter SAMBA\share‘s password:
Anonymous login successful
OS=[Windows 6.1] Server=[Samba 4.7.1]
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
guohui Disk guohui
IPC$ IPC IPC Service (Samba 4.7.1)
Anonymous login successful
OS=[Windows 6.1] Server=[Samba 4.7.1]
Server Comment
--------- -------
Workgroup Master
--------- -------
//将samba服务器的共享资源guohui挂载到客户机本地 (B)
以cifs的方式将IP地址以DDD身份挂载到
[root@guohui ~]# mkdir -p /opt/guohui
[root@guohui ~]# mount -t cifs //192.168.56.11/guohui /opt/guohui/ -o username=share,password=123
[root@guohui ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
tmpfs 98M 0 98M 0% /run/user/0
//192.168.56.11/guohui 17G 4.0G 14G 24% /opt/DDD
[root@guohui opt]# cd guohui (B)在目录下创建
[root@guohui guohui]# mkdir 1
[root@guohui ~]# ls /opt/guohui (A)验证
1
总结,请务必先关闭防火墙
2.如何配置匿名共享
查看防火墙状态并关闭
[root@guohui ~]# systemctl status firewalld
[root@guohui ~]# systemctl disable firewalld
[root@guohui ~]# systemctl stop firewalld
[root@guohui ~]# setenforce 0
//使用yum安装samba服务器
[root@guohui ~]# yum -y install samba-*
//在全局配置中添加
[root@guohui ~]# vim /etc/samba/smb.conf
[global]
workgroup = SAMBA
security = user
map to guest = Bad User //添加本行命令,固定式
//创建一个共享目录
[root@guohui ~]# mkdir /opt/guohui1
[root@guohui ~]# chmod 777 /opt/guohui1
[root@guohui ~]# ll /opt/
drwxrwxrwx. 2 root root 6 8月 6 19:45 guohui1
//配置共享
[root@guohui ~]# vim /etc/samba/smb.conf
[root@guohui ~]# tail -7 /etc/samba/smb.conf
[guohui1]
comment = guohui1
path = /opt/guohui1
browseable = yes
guest ok = yes
writable = yes
public = yes
//启动smb服务
[root@guohui ~]# systemctl start smb
//在客户机查看samba服务器的共享资源,发现guohui1 //(B)
[root@guohui ~]# smbclient -L 192.168.56.11 -U ‘Bad User‘
Enter SAMBA\Bad User‘s password:
OS=[Windows 6.1] Server=[Samba 4.7.1]
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
guohui1 Disk guohui1
IPC$ IPC IPC Service (Samba 4.7.1)
//将samba服务器的共享资源guohui1挂载到客户机本地
[root@guohui ~]# mkdir -p /opt/guohui1
[root@guohui ~]# mount -t cifs //192.168.56.11/guohui1 /opt/guohui1/ -o username=‘Bad User‘
Password for Bad User@//192.168.56.11/guohui1: //空格
[root@guohui ~]# df -h
//192.168.56.11/guohui1 17G 4.0G 14G 24% /opt/guohui1
//在客户机上进入共享目录创建新文件
[root@guohui ~]# cd /opt/guohui1 (B)在目录下创建
[root@guohui guohui1]# mkdir 1
//samba服务器验证
[root@guohui ~]# ls /opt/guohui1 (A)验证
1
总结:
//使用windows登陆samba服务器,用户(Bad User),无需密码
1.放置windows里的文件到samba服务器里 // 在windows系统里 (\+ip)登陆
2.放置有一个window文件进入samba服务器,并使用samba服务器查看
[root@guohui guohui1]# mkdir 1
[root@guohui guohui1]# ls
1 1.txt
linux——如何搭建samba共享目录中的,用户认证共享及匿名用户共享?(不分系统)
标签:ip地址 ddd 挂载点 txt star file reload user rom
原文地址:http://blog.51cto.com/13859004/2155835