实验01:Samba匿名共享 一、环境准备 1. 检查安装软件包 [iyunv@dhcpser~]#rpm -q samba-client samba samba-common packagesamba-client is not installed package sambais not installed packagesamba-common is not installed [iyunv@dhcpser~]# cd /etc/yum.repos.d/ [rhel-server] name=Red HatEnterprise Linux Server baseurl=file:///misc/cd/Server enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //放入rhel5.9 iso 2. 修改配置文件 [iyunv@dhcpser~]# vim /etc/samba/smb.conf 289 [tools] ... 74 workgroup = Tarena //工作组名 75 server string = Win File Ser //服务器描述 ... 89 log file = /var/log/samba/%m.log //日志路径 ... 91 max log size = 50 //最大日志容量 ... 101 security = share/ user //匿名共享/用户认证 ... 221 load printers = no //屏蔽共享时看到的打印图标 ... 290 comment = Tools Public //对此文件夹的说明字 291 path = /usr/src //共享目录的实际位置 292 public = yes //是否所有人可用 293 read only = yes //权限为只读 browseable = on/yes //为隐藏共享 writable = on //是否可写 .. .. 3. 确认修改 [iyunv@dhcpser~]# testparm [iyunv@dhcpser~]# service smb restart [iyunv@dhcpser~]# chkconfig smb on 一、基于客户端修改 1. Win7页面测试 \\192.168.10.253 2. Linux页面测试 [iyunv@localhost~]# yum -y install samba-client [iyunv@localhost~]# smbclient -L 192.168.10.253 //查询共享 [iyunv@localhost~]# smbclient //192.168.10.253/tools //基于命令行 [iyunv@localhost~]# mkdir -p /data/smb [iyunv@localhost~]# mount -t cifs //192.168.10.253/tools /data/smb/ //使用mount将共享目录挂载到本地 [iyunv@localhost~]# vim /etc/fstab //192.168.10.253/tools /data/smb cifs defaults 0 0 [iyunv@localhost~]# grep smb /etc/fstab
实验02:Samba用户验证 一、环境准备 1. 新建相应账户与samba的密码 [iyunv@localhost~]# useradd nick [iyunv@localhost~]# useradd tom [iyunv@localhost~]# echo "redhat" | passwd --stdin nick [iyunv@localhost~]# echo "redhat" | passwd --stdin tom [iyunv@localhost~]# pdbedit -a nick //将指定的系统用户添加为共享帐号 [iyunv@localhost~]# pdbedit -a tom 注:pdbedit -L nick 查看共享帐号信息 pdbedit -x nick 删除指定的共享帐号 若要冲设密码,可执行smbpasswd 用户名
2. 修改主配置文件 [iyunv@dhcpser~]# vim /etc/samba/smb.conf ... 101 security = user //启用用户认证 ... 289 [tools] 290 comment = Tools Public 291 path = /usr/src //指定共享路径 292 public = no //不对所有人开放 293 valid users = nick,tom //共享帐号列表,指定合法用户 294 write list = tom //tom用户可读可写 295 read only = yes //默认的权限为只读 296 directory mask = 0755 //上传目录的权限 297 create mask = 0644 //上传文件的权限 ... [iyunv@localhost~]# setfacl -m u:tom:rwx /usr/src/ 3. 启动服务 [iyunv@dhcpser ~]#service smb restart 一、客户端测试 [iyunv@localhost~]# smbclient -U nick //192.168.10.10/tools [iyunv@localhost~]# mount -o username=nick //192.168.10.10/tools /data/smb
实验03:Samba账户别名与访问地址控制 一、环境准备 1. 修改Samba用户别名文件 [iyunv@localhost~]# vim /etc/samba/smbusers # Unix_name =SMB_name1 SMB_name2 ... root =administrator admin nobody = guestpcguest smbguest nick = jim 2. 修改主配置文件 [iyunv@dhcpser~]# vim /etc/samba/smb.conf ... 76 username map = /etc/samba/smbusers ... 289 [tools] 290 comment = Tools Public 291 path = /usr/src 292 public = no 293 valid users = nick,tom 294 write list = tom 295 read only = yes 296 directory mask = 0755 297 create mask = 0644 298 hosts allow = 192.168.10.5 3. 启动服务 [iyunv@dhcpser ~]#service smb restart 一、客户端测试 [iyunv@localhost~]# smbclient -U nick //192.168.10.10/tools [iyunv@localhost~]# mount -o username=nick //192.168.10.10/tools /data/smb
|