一、创建samba共享,共享目录为/data,要求:(描述完整的过程)mysql
1)共享名为shared,工做组为magedu;sql
2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;shell
3)添加samba用户gentoo,centos和ubuntu,密码均为“mageedu”;数据库
4)此samba共享shared仅容许develop组具备写权限,其余用户只能以只读方式访问;ubuntu
5)此samba共享服务仅容许来自于172.16.0.0/16网络的主机访问;vim
创建共享samba目录文件,建立工做组,添加用户:centos
]# mkdir -pv /data/sharedbash
[root@localhost CA]# groupadd develop服务器
[root@localhost CA]# useradd -G develop gentoo网络
[root@localhost CA]# useradd -G develop centos
[root@localhost CA]# useradd ubuntu
[root@localhost CA]# echo gentoo | passwd --stdin gentoo
更改用户 gentoo 的密码 。
passwd:全部的身份验证令牌已经成功更新。
[root@localhost CA]# echo gentoo | passwd --stdin centos
更改用户 centos 的密码 。
passwd:全部的身份验证令牌已经成功更新。
[root@localhost CA]# echo gentoo | passwd --stdin ubuntu
更改用户 ubuntu 的密码 。
passwd:全部的身份验证令牌已经成功更新。
2.安装samba :yum install samba
1)编辑smb.conf 文件 vim /etc/samba/smb.conf
3 添加samba用户gentoo,centos和Ubuntu,密码为各自用户名:
]
# vim /etc/samba/smb.conf后面添加
//
自定义共享:
[shared]
comment = shared
test
file
path =
/data/shared
writable =
yes
guest ok =
yes
测试配置文件是否有错误及生效
#] testparm
4 启动samba服务:]# systemctl start smb
5 配置共享文件权限:共享权限和文件系统权限两者缺一不可.必须都拥有写权限才能写入.
[root@localhost ~]# setfacl -m group:develop:rwx /data/shared
[root@localhost ~]# set -m user:ubuntu:rx /data/shared
[root@localhost ~]# ls -ld /data/shared
drwxrwxr-x+ 2 root root 6 8月 28 05:49 /data/shared
6 交互式数据访问:
7 测试结果
首先以一台cent6客户端分别用centos和Ubuntu用户登陆samba服务,前者可上传文件,后者则只读:
二、搭建一套文件vsftp文件共享服务,共享目录为/ftproot,要求:(描述完整的过程)
1)基于虚拟用户的访问形式;
2)匿名用户只容许下载,不容许上传;
3)禁锢全部的用户于其家目录当中;
4)限制最大并发链接数为200:;
5)匿名用户的最大传输速率512KB/s
6)虚拟用户的帐号存储在mysql数据库当中。
7)数据库经过NFS进行共享
实验环境以下
ip |
用途 |
192.168.10.132 |
mysql+vsftp |
192.168.10.128 | nfs |
1 安装nfs服务器
[root@cent6 /]# yum install nfsutil* rpcbind #安装nfs和rpcbind服务所需软件包
[root@cent6 /]# mkdir /nfs #建立共享文件夹
[root@cent6 ~]# groupadd -g 1001 mysql #添加mysql组
[root@cent6 ~]# useradd -u 1001 -g 1001 mysql #添加mysql用户
[root@cent6 ~]# chown mysql:mysql /nfs #修改/nfs属组为mysql,为以后挂载到mysql服务器上作datadir作准备
[root@cent6 /]# vim /etc/exports #编辑/etc/exports文件,添加权限
/nfs 192.168.10.132(rw,sync,fsid=0,no_root_squash)
[root@cent6 /]# systemctl start rpcbind.service ##启动rpcbind服务
[root@cent6 /]# systemctl start nfs-server.service #启动nfs服务
若是是Centos6的请注意
启动rpcbind rpcbind是6.0版本后默认的RPC服务,因此要先于nfs启动。若是不启动rpcidmap则会形成用户权限的映射错误,用户的权限看起来是一串数字。
#] /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
#] /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
2 客户端挂载nfs文件夹
[root@localhost /]# mkdir /mydata/data -pv #建立挂载路径
[root@localhost /]# mount -t nfs 192.168.10.128:/nfs /mydata/data #挂载nfs目录到/mydata/data
若是提示错误为mount.nfs: access denied by server while mounting
去nfs服务器修改,添加insecure便可,而后重启nfs服务
[root@cent6 /]# vim /etc/exports #编辑/etc/exports文件,添加权限
/nfs 192.168.10.132(insecure,rw,sync,fsid=0,no_root_squash)
3 安装mysql
[root@localhost ~]# yum install -y mariadb mariadb-develdatadir=/mydata/data
socket=/var/lib/mysql/mysql.sock
character-set = utf84 建立数据库
5 pam-mysql配置
[root@localhost pam_mysql-0.7RC1]# vim /etc/pam.d/vsftpd #编辑配置文件,添加以下两行6 修改vsftp配置
[root@localhost /]# useradd -s /sbin/nologin -d /var/ftproot vuser #创建虚拟用户映射的系统用户及对应目录7 运行结果
[root@cent6 /]# ftp 192.168.10.132 Connected to 192.168.10.132 (192.168.10.132). 220 (vsFTPd 3.0.2) Name (192.168.10.132:root): vsftpd1 #用虚拟帐号登录 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> lcd /shell/ Local directory now /shell ftp> get test #下载文件 local: test remote: test 227 Entering Passive Mode (192,168,10,132,195,159). 150 Opening BINARY mode data connection for test (0 bytes). 226 Transfer complete. ftp> put case.sh #上传文件 local: case.sh remote: case.sh 227 Entering Passive Mode (192,168,10,132,234,27). 150 Ok to send data. 226 Transfer complete. 365 bytes sent in 9.2e-05 secs (3967.39 Kbytes/sec) ftp>