N22-第十三周作业

1、建立samba共享,共享目录为/data,要求:(描述完整的过程)
  1)共享名为shared,工作组为magedu;
  2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;
  3)添加samba用户gentoo,centos和ubuntu,密码均为“mageedu”;
  4)此samba共享shared仅允许develop组具有写权限,其他用户只能以只读方式访问;
  5)此samba共享服务仅允许来自于172.16.0.0/16网络的主机访问;

添加用户和组:

[root@localhost ~]# groupadd develop

[root@localhost ~]# useradd -G develop gentoo
[root@localhost ~]# useradd -G develop centos
[root@localhost ~]# useradd -G develop ubuntu

设置用户密码:

[root@localhost ~]# echo "gentoo" |passwd –stdin gentoo

[root@localhost ~]# echo "centos" |passwd –stdin centos

[root@localhost ~]# echo "ubuntu" |passwd –stdin ubuntu

添加samba用户:

[root@localhost samba]# smbpasswd -a gentoo
New SMB password:
Retype new SMB password:
Added user gentoo.
[root@localhost samba]# smbpasswd -a centos
New SMB password:
Retype new SMB password:
Added user centos.
[root@localhost samba]# smbpasswd -a ubuntu
New SMB password:
Retype new SMB password:
Added user ubuntu.

修改共享目录/data/的acl:

[root@localhost ~]# setfacl -m g:develop:rwx /data/

编辑samba配置文件:

[root@localhost ~]# vim /etc/samba/smb.conf

workgroup = magedu    

hosts allow = 172.16.0.0/16

[shared]
        comment = test
        pahth = /data
        browseable = yes

        guest ok = yes

        writable = no
        write list = @develop

重新加载samba服务:

[root@localhost ~]# systemctl reload smb.service

测试centos用户:

[root@localhost ~]# smbclient //192.168.1.120/shared -U centos
Enter centos's password:
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
smb: \> put fstab
putting file fstab as \fstab (254.9 kb/s) (average 254.9 kb/s)
测试gentoo用户:

root@localhost ~]# smbclient //192.168.1.120/shared -U gentoo
Enter centos's password:
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
smb: \> put crontab
putting file crontab as \crontab (146.8 kb/s) (average 146.8 kb/s)

测试ubuntu用户:

[root@localhost ~]# smbclient //192.168.1.120/shared -U ubuntu
Enter ubuntu's password:
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
smb: \> get fstab
getting file \fstab of size 783 as fstab (191.2 KiloBytes/sec) (average 191.2 KiloBytes/sec)
smb: \> put hosts
NT_STATUS_ACCESS_DENIED opening remote file \hosts

2、搭建一套文件vsftp文件共享服务,共享目录为/ftproot,要求:(描述完整的过程)
1)基于虚拟用户的访问形式;

2)匿名用户只允许下载,不允许上传;

3)禁锢所有的用户于其家目录当中;

4)限制最大并发连接数为200:;

5)匿名用户的最大传输速率512KB/s

6)虚拟用户的账号存储在mysql数据库当中。
7)数据库通过NFS进行共享。
安装mariadb-server和vsftpd

[root@localhost ~]# yum install mariadb-server

[root@localhost ~]# yum install vsftpd

编译安装pam-mysql:

[root@localhost ~]#yum groupinstall "Development Tools" "Server Platform Development"

[root@localhost ~]#yum install pam-devel openssl-devel mariadb-devel

[root@localhost pam_mysql-0.7RC1]#  ./configure –prefix=/user/local/pam-mysql –with-openssl –with-mysql=/usr –with-pam=/usr –with-pam-mods-dir=/usr/lib64/security

[root@localhost pam_mysql-0.7RC1]#  make && make install

查看是否安装成功:

[root@localhost ~]# ls /lib64/security/ |grep pam_mysql
pam_mysql.la
pam_mysql.so
在mariadb数据库上创建虚拟用户:

[root@localhost pam_mysql-0.7RC1]# systemctl start mariadb.service

[root@localhost ~]# mysql
MariaDB [(none)]> create database vsftpd;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use vsftpd
Database changed
MariaDB [vsftpd]> create table users(
    -> id int auto_increment not null primary key,
    -> name char(30) not null,
    -> password char(48) binary not null );
Query OK, 0 rows affected (0.01 sec)
MariaDB [vsftpd]> insert into users (name,password) values ('tom',password('magedu'));
Query OK, 1 row affected (0.00 sec)
MariaDB [vsftpd]> insert into users (name,password) values ('jerry',password('magedu.com'));
Query OK, 1 row affected (0.00 sec)
MariaDB [vsftpd]> grant select on vsftpd.* to vsftpd@localhost identified by 'magedu';
Query OK, 0 rows affected (0.01 sec)
MariaDB [vsftpd]> grant select on vsftpd.* to vsftpd@'127.0.0.1' identified by 'magedu';
Query OK, 0 rows affected (0.00 sec)
MariaDB [vsftpd]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [vsftpd]> exit
Bye

创建虚拟用户的映射用户:

[root@localhost ~]# useradd -s /sbin/nologin -d /ftproot vuser

[root@localhost ~]# chmod go+rx /ftproot

[root@localhost ~]# chmod -w /ftproot
编辑vsftpd配置文件:
[root@localhost ~]# vim /etc/vsftpd//vsftpd.conf

anonymous_enable=YES 

local_enable=YES
write_enable=YES
anon_upload_enable=NO

chroot_local_user=YES
max_clients=200

anon_max_rate=512000

guest_enable=YES
guest_username=vuser
pam_service_name=vsftpd.mysql
启动vsftpd服务:

[root@localhost ~]# systemctl start vsftpd.service
在另一台主机上验证:

[root@localhost ~]# ftp 192.168.1.120
Connected to 192.168.1.120 (192.168.1.120).
220 (vsFTPd 3.0.2)
Name (192.168.1.120:root): tom
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
共享数据库:

[root@localhost ~]# vim /etc/exports

/mydata/data        192.168.1.0/24(rw)

[root@localhost ~]#exportfs -r

原创文章,作者:heianyangguo,如若转载,请注明出处:http://www.178linux.com/57061

(0)
heianyangguoheianyangguo
上一篇 2016-11-13
下一篇 2016-11-14

相关推荐

  • 软件包管理–RPM YUM

    包管理器 二进制应用程序的组成部分 二进制文件,配置文件,说明文档,库文件 程序包管理器 Debian  deb文件  dpkg包管理器 Redhat  rpm文件  rpm包管理器                   &nbsp…

    Linux干货 2016-08-21
  • linux文件管理类、bash的基础命令以及习题。

    文件管理工具:cp, mv, rm cp命令:copy 源文件:目标文件; 单源复制:cp [OPTION]… [-T] SOURCE DEST 多源复制:cp [OPTION]… SOURCE… DIRECTORY         cp&nb…

    Linux干货 2016-11-05
  • linux基础学习-网络基础

    一、OSI七层模型 二、TCP/IP模型         三次握手原理 三、常见服务的默认端口 四、IP地址、子网划分基础知识     通信原理:一般数据的交互产生是在应用层(TCP/IP模型),应用层以下可以看成是搬运工,不同层的协议定义了不同的搬运工的工作内容,直到最后,把数…

    Linux干货 2016-09-05
  • 马哥教育网络班22期-第3周博客作业

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 [root@zck ~]# who | cut -d ' ' -f1 | sort -u roo root 2、取出最后登录到当前系统的用…

    Linux干货 2016-08-30
  • httpd功能配置之https

       HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL。HTTPS使用443端口进行通信。    …

    Linux干货 2016-03-13
  • 三次握手,四次挥手

    TCP/IP协议的详细信息参看《TCP/IP协议详解》三卷本。 在谈及TCP建立连接和释放连接过程,先来简单认识一下TCP报文段首部格式的的几个名词(这里只是简单说明,具体请查看相关教程)下面是TCP报文格式图:     序列号seq:占4个字节,用来标记数据段的顺序,TCP把连接中发送的所有数据字节都编上一个序号,第一个字节的…

    2017-09-03

评论列表(1条)

  • luoweiro
    luoweiro 2016-11-29 22:30

    作业整体步骤完成的不错,但是缺少对原理的总结。