1.7、samba 部署和优化 -1
1、samba:可以将linux 目录共享出来,供windows系统访问;类似windows系统共享目录
2、安装 samba 服务:
# yum install -y samba samba-client
3、查看samba配置文件
# cp /etc/samba/smb.conf /root/smb.conf.bak
# sed -i '/^#/d' /etc/samba/smb.conf
# sed -i '/^$/d' /etc/samba/smb.conf
# sed -i '/^;/d' /etc/samba/smb.conf
# vim /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
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
1.8 samba 部署和优化-2
1、需求:共享一个目录,任何人都可以访问,不需要输入用户名和密码,但共享目录只能读取不能写入
2、修改 samba 配置文件
# vim /etc/samba/smb.conf
修改:
security = share
添加:
[share]
comment = share all
path = /data/samba
browseable = yes
public = yes
writable = no
保存退出
3、测试
# /etc/init.d/smb start
windows 测试:
\\IP \\192.168.230.130 //IP
客户端 Linux 系统测试登录samba 共享
# yum install -y samba-client
# smbclient //IP /模块名
# smbclient //192.168.230.130/share
4、客户端 linux 系统挂载 Samba
# yum install -y cifs-utils
# mount -t cifs //IP /模块名 /samba/
# mount -t cifs //192.168.230.130/share /samba/
1.9、samba 部署和优化-3
1、需求:输入用户名和密码访问Samba 访问共享资源,并且资源可读可写
2、修改 samba 配置文件
# vim /etc/samba/smb.conf
修改:
security = user
添加:
[cc]
comment = share for users
path = /data/samba/
browseable = yes
writable = yes
public = no
##删除之前无需用户和密码能访问samba的模块
保存退出
3、创建samba 用户
# useradd smbuser
# chown -R smbuser:smbuser /data/samba/
# pdbedit -a smbuser ## 建立一个samba 虚拟用户,用户名需要和Linux系统用户名一致
# pdbedit -h##查看帮助内容
# pdbedit -L ## 查看 samba 用户列表
# pdbedit -x smbuser ##删除一个samba 虚拟用户
4、重启 samba 服务
# /etc/init.d/smb restart
5、测试:
windows 测试:
\\IP \\192.168.230.130 //IP
输入虚拟账户的账号密码登录
客户端 Linux 系统测试:
# smbclient -Usmbuser //192.168.230.130/cc ## -U 指定用户
6、客户端挂载 samba
# mount -t cifs -o username=smbuser,password=123456 //IP/模块名 /samba/
# mount -t cifs -o username=smbuser,password=123456 //192.168.230.130/cc /samba/
7、客户端指定密码文件挂载
# vim auth.smb
username=smbuser
password=123456
domain=MYGROUP
# chmod 600 auth.smb
# mount -t cifs -o credentials=/root/auth.smb //192.168.1.200/database /samba/
转载于:https://blog.51cto.com/13673885/2162990