第十三周作业

“1、建立samba共享,共享目录为/data,要求:(描述完整的过程)

  1)共享名为shared,工作组为magedu

  2)添加组develop,添加用户gentoo,centosubuntu,其中gentoocentosdevelop为附加组,ubuntu不属于develop组;密码均为用户名;

  3)添加samba用户gentoo,centosubuntu,密码均为“mageedu”;

  4)此samba共享shared仅允许develop组具有写权限,其他用户只能以只读方式访问;

  5)此samba共享服务仅允许来自于172.16.0.0/16网络的主机访问;

1.下载samba

[root@localhost ~]# yum install samba –y

2.创建develop组以及用户。
[root@localhost ~]# groupadd develop
[root@localhost ~]# useradd gentoo -G develop
[root@localhos/ft ~]# useradd centos -G develop
[root@localhost ~]# useradd ubuntu
[root@localhost ~]# for i in gentoo centos ubuntu ;do echo “$i” |passwd –stdin $i;done
更改用户 gentoo 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 centos 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 ubuntu 的密码 。
passwd:所有的身份验证令牌已经成功更新
[root@localhost ~]# smbpasswd -a gentoo
New SMB password:
Retype new SMB password:
Added user gentoo.

3.创建samba用户

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

4.创建共享目录/data
[root@CentOS7 ~]# mkdir /data
[root@CentOS7 ~]# chgrp develop /data
[root@CentOS7 ~]# chmod g+w /data

5.按需修改配置文件(/etc/samba/smb.conf),开启服务(需开启smb和nmb服务)

[root@CentOS7 samba]# vim /etc/samba/smb.conf
[global]
        workgroup = mageedu
[shared]
     comment = test data
     path = /data
     read only = Yes
    write list = @develop
    hosts allow = 192.168.1.0/24
    browseable = No
[root@CentOS7 ~]# systemctl start smb.service
[root@CentOS7 ~]# systemctl start nmb.service

6.用客户端命令测试
[root@CentOS7 ~]# smbclient //192.168.1.108/shared -U centos
Enter centos’s password: 
Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4]
smb: \> lcd /etc
smb: \> put issue
putting file issue as \issue (0.5 kb/s) (average 0.5 kb/s)

2、搭建一套文件vsftp文件共享服务,共享目录为/ftproot,要求:(描述完整的过程)

  1)基于虚拟用户的访问形式;

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

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

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

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

  6)虚拟用户的账号存储在mysql数据库当中。

  7)数据库通过NFS进行共享。


前提关闭防火墙和seliunx(192.168.1.106)

1.开启NFS服务,建立共享目录并设定权限(下载nfs-utils),供客户端共享。
[root@localhost /]# yum install nfs-utils –y
[root@localhost /]# mkdir /mydata
[root@localhost /]# vim /etc/exports  # NFS配置文件
/mydata 192.168.1.0/24(rw,sync,no_root_squash)
[root@localhost mydata]# systemctl start nfs.service
[root@localhost mydata]# exportfs 
/mydata       192.168.1.0/24
[root@localhost mydata]# showmount -e 192.168.1.109  #查看共享目录
Export list for 192.168.1.109:
/mydata 192.168.1.0/24

2.安装配置mariadb数据库
(mariadb-server,mariadb-devel,openssl-devel, pam-devel)

[root@localhost /]# yum install mariadb-server mariadb-devel openssl-devel –y

修改数据库配置(目录为/mydata),建立vsftpd库以及users表;

[root@CentOS7 textmysql]# chown -R mysql.mysql /mydata
[root@CentOS7 textmysql]# systemctl start mariadb.service
[root@CentOS7 /]# rm -fr /var/lib/mysql
[root@CentOS7 etc]# vim /etc/my.cnf    #修改mariadb的配置文件
[mysqld]
datadir=/mydata
socket=/mydata/mysql.sock
[mysqladmin]
socket=/mydata/mysql.sock
[root@localhost /]# mysql_install_db –defaults-file=/etc/my.cnf –datadir=/mydata –user=mysql  #初始化
[root@localhost /]# systemctl restart mariadb.service
[root@CentOS7/]# ln -s /textmysql/mysql.sock /var/lib/mysql/mysql.sock
[root@CentOS7 /]# mysqladmin -u root password ‘111111’ 
[root@CentOS7 /]# mysql -uroot -p111111  #创建数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> quit
Bye
[root@CentOS7 /]# mysql -uroot -p111111
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

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) NOT NULL );
Query OK, 0 rows affected (0.04 sec)

MariaDB [vsftpd]> desc users;
+———-+———-+——+—–+———+—————-+
| Field    | Type     | Null | Key | Default | Extra          |
+———-+———-+——+—–+———+—————-+
| ID       | int(11)  | NO   | PRI | NULL    | auto_increment |
| name     | char(30) | NO   |     | NULL    |                |
| password | char(48) | NO   |     | NULL    |                |
+———-+———-+——+—–+———+—————-+
3 rows in set (0.05 sec)

MariaDB [vsftpd]>  INSERT INTO users(name,password) VALUES (‘tom’,password(‘mageedu’));
Query OK, 1 row affected (0.05 sec)

MariaDB [vsftpd]>  INSERT INTO users(name,password) VALUES (‘jerry’,password(‘mageedu’));
Query OK, 1 row affected (0.01 sec)

MariaDB [vsftpd]> select * from users;
+—-+——-+——————————————-+
| ID | name  | password                                  |
+—-+——-+——————————————-+
|  1 | tom   | *9A94EE7D14C10908118B62D2DA88E6932E11E438 |
|  2 | jerry | *9A94EE7D14C10908118B62D2DA88E6932E11E438 |
+—-+——-+——————————————-+
2 rows in set (0.02 sec)


Database changed
MariaDB [vsftpd]> grant select on vsftpd.* to vsftpd@localhost identified by ‘111111’;
Query OK, 0 rows affected (0.04 sec)

MariaDB [vsftpd]> grant select on vsftpd.* to vsftpd@127.0.0.1 identified by ‘111111’;

MariaDB [vsftpd]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [vsftpd]> quit
Bye

3.编译安装pam_mysql
[root@localhost /]# tar -xf pam_mysql-0.7RC1.tar.gz
[root@localhost /]# cd pam_mysql-0.7RC1
[root@localhost pam_mysql-0.7RC1]# ./configure –with-mysql=/usr –with-pam=/usr –with-pam-mods-dir=/usr/lib
[root@localhost pam_mysql-0.7RC1]# make && make install

4.虚拟用户的账号保存在mariadb中,新建pam配置文件(目录/etc/pam.d下)

[root@CentOS7 /]# vim /etc/pam.d/vsftpd.mysql
auth required pam_mysql.so user=vsftpd passwd=111111 host=localho
st db=vsfftpd tables=users usercolumn=name passwdcolumn=password
crpyt=2
account required pam_mysql.so user=vsftpd passwd=111111 host=localhost db=vsfftpd tables=users usercolumn=name passwdcolumn=password crpyt=2

5.安装vsftpd,修改配置

[root@CentOS7 /]# yum install vsftpd -y
[root@CentOS7 /]# systemctl start vsftpd.service

修改配置(/etc/vsftpd/vsftpd.conf文件)
[root@CentOS7 /]# vim /etc/vsftpd/vsftpd.conf
guest_enable=YES
guest_username=vuser
anon_max_rate=512000
anon_world_readable_only=YES
max_clients=200
anon_other_write_enable=YES
chroot_local_user=YES
write_enable=YES
anon_root=/ftproot/pub
pam_service_name=vsftpd.mysql

创建共享目录/ftproot,以及虚拟用户身份vuser

[root@CentOS7 /]# useradd -s /sbin/nologin -d /ftproot/
[root@CentOS7 /]# chmod 755 /ftproot/
[root@CentOS7 /]# ls /ftproot/ -ld
drwxr-xr-x. 5 vuser vuser 97 8月  11 11:11 /ftproot/
[root@CentOS7 /]# chmod -w /ftproot/
[root@CentOS7 /]# mkdir -p /ftproot/{put,upload}
 
重启服务
[root@CentOS7 /]#  systemctl restart vsftpd.service


测试(客户端192.168.1.109)

[root@localhost /]# ftp 192.168.1.106
Connected to 192.168.1.106 (192.168.1.106).
220 (vsFTPd 3.0.2)
Name (192.168.1.106:root): tom
331 Please specify the password.
Password:
230 Login successful.   #登录成功
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,1,106,40,200).
150 Here comes the directory listing.
drwxr-xr-x    2 0        0              18 Aug 11 03:47 pub
drwxr-xr-x    2 0        0               6 Aug 11 09:35 put
drwxr-xr-x    2 0        0               6 Aug 11 09:35 upload
226 Directory send OK.
ftp> cd /pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (192,168,1,106,165,9).
150 Here comes the directory listing.
-rw-r–r–    1 0        0             689 Aug 11 03:47 fstab
226 Directory send OK.
ftp> get fstab
local: fstab remote: fstab   #测试下载
227 Entering Passive Mode (192,168,1,106,66,241).
150 Opening BINARY mode data connection for fstab (689 bytes).
226 Transfer complete.
689 bytes received in 0.0385 secs (17.91 Kbytes/sec) #成功下载
ftp> put issue   # 测试上传
local: issue remote: issue
227 Entering Passive Mode (192,168,1,106,89,148).
553 Could not create file. #不能上传文件
ftp>

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

(0)
ning407631632ning407631632
上一篇 2017-08-12 23:18
下一篇 2017-08-13

相关推荐

  • 小型网站MYSQL问题一:MyISAM转Innodb的方法

    故事背景:之前公司的数据库存储引擎全部为MyISAM,数据量和访问量都不是很大,也一直没有什么问题。我最近接手一些运维工作,兼DBA,因为业务上面涉及到钱,所以决定换成支持事物的innodb。下面将操作步骤记录以下。 1、导出mydb数据库的表结构 mysqldump -d -uxxx -p mydb &gt…

    Linux干货 2015-12-19
  • 网络通信安全基础OpenSSL

    OpenSSL: NIST: 保密性: 数据保密性 隐私性 完整性: 数据完整性 系统完整性 可用性  安全攻击: 被动攻击:窃听 主动攻击:伪装、重放、消息篡改、拒绝服  安全机制: 加密、数字签名、访问控制、数据完整性、认证交换、流量填充、路由控制、公证 安全服务: 认证 访问控制 数据保密性 连接保密性 无连接保密性 选择域保密性 …

    Linux干货 2015-09-06
  • Linux的哲学思想

    初学Linux,了解一下Linux的哲学思想,对学习Linux还是非常有帮助的。 在了解Linux的哲学思想之前,可以先考虑一下,现在我们所学的Linux系统到底是面向什么应用场景而研发和使用的?个人认为:面向企业,是一个服务器操作系统。其所关注的地方是:高性能、可靠性、易维护性。 基于上述方面的考虑,Linux系统在构建和设计的时候,遵循了如下的哲学思想进…

    Linux干货 2017-08-30
  • bash进阶学习ing

    使用read命令来接受输入使用read来把输入值分配给一个或多个shell变量: -p 指定要显示的提示 -t TIMEOUT read 从标准输入中读取值,给每个单词分配一个变量所有剩余单词都被分配给最后一个变量read -p “Enter a filename: “ FILE 条件选择if语句选择执行:注意: if语句可嵌套单分支if 判断条件: the…

    Linux干货 2016-08-21
  • Centos6基于虚拟主机的Lamp配置bbs、Blog、PhpMyAdmin应用程序

    Centos6实现基于虚拟主机的各应用程序搭建: 一、配置三个基于名称的虚拟主机;       虚拟主机一、discuzX       虚拟主机二、wordpress       虚拟主机三…

    2017-06-01
  • 马哥教育网络班第25期-第1周作业

    一、计算机的组成及其功能 计算机由硬件与软件组成 硬件     1、运算器                           &…

    Linux干货 2016-12-05