第十五周学习作业

Posted 三石头

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第十五周学习作业相关的知识,希望对你有一定的参考价值。

1、实现基于mysql验证的vsftpd虚拟用户访问

第十五周学习作业_服务器

1.1数据库安装并新建vsftpd虚拟账户

##注意:MySQL8.0由于取消了PASSWORD()函数不支持,因此选择Mariadb
[root@CentOS84 ~]# yum install mariadb-server
[root@CentOS84 ~]# systemctl start mariadb.service
[root@CentOS84 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \\g.
Your MariaDB connection id is 8
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, 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.000 sec)
MariaDB [vsftpd]> create table users(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,name CHAR(50) BINARY NOT NULL,password CHAR(48) BINARY NOT NULL);
Query OK, 0 rows affected (0.004 sec)
MariaDB [(none)]> use vsftpd

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

MariaDB [vsftpd]> insert into users(name,password) values(user01,password(123456));
Query OK, 1 row affected (0.002 sec)

MariaDB [vsftpd]> insert into users(name,password) values(user02,password(123456));
Query OK, 1 row affected (0.001 sec)
MariaDB [vsftpd]> select * from users;
+----+------------+-------------------------------------------+
| id | name | password |
+----+------------+-------------------------------------------+
| 1 | user01 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 2 | user02 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+----+------------+-------------------------------------------+
2 rows in set (0.000 sec)
MariaDB [vsftpd]> grant select on vsftpd.* to vsftpd@10.10.10.% identified by 123456;
Query OK, 0 rows affected (0.003 sec)

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

1.2 vsftp服务器安装配置

[root@centos79 ~]# yum -y install vsftpd gcc gcc-c++ make mariadb-devel pam-devel
[root@centos79 ~]# wget https://jaist.dl.sourceforge.net/project/pam-mysql/pam-mysql/0.7RC1/pam_mysql-0.7RC1.tar.gz
[root@centos79 ~]# tar xf pam_mysql-0.7RC1.tar.gz
[root@centos79 ~]# cd pam_mysql-0.7RC1/
[root@centos79 pam_mysql-0.7RC1]# ./configure --with-pam-mods-dir=/lib64/security
[root@centos79 pam_mysql-0.7RC1]# make install
[root@centos79 pam_mysql-0.7RC1]# ls -l /lib64/security/pam_mysql*
-rwxr-xr-x. 1 root root 882 Mar 21 23:55 /lib64/security/pam_mysql.la
-rwxr-xr-x. 1 root root 141712 Mar 21 23:55 /lib64/security/pam_mysql.so

[root@centos79 pam_mysql-0.7RC1]# cat > /etc/pam.d/vsftpd.mysql << EOF
auth required pam_mysql.so user=vsftpd passwd=123456 host=10.10.10.10 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2
account required pam_mysql.so user=vsftpd passwd=123456 host=10.10.10.10 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2
EOF
[root@centos79 pam_mysql-0.7RC1]# useradd -s /sbin/nologin -d /data/ftproot -r vuser
[root@centos79 pam_mysql-0.7RC1]# mkdir -pv /data/ftproot/upload
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/ftproot’
mkdir: created directory ‘/data/ftproot/upload’
[root@centos79 pam_mysql-0.7RC1]# setfacl -m u:vuser:rwx /data/ftproot/upload

[root@centos79 pam_mysql-0.7RC1]# tail -10 /etc/vsftpd/vsftpd.conf
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd.mysql ##修改
userlist_enable=YES
tcp_wrappers=YES
guest_enable=YES ##新增
guest_username=vuser ##新增
user_config_dir=/etc/vsftpd/conf.d/ ##新增

[root@centos79 pam_mysql-0.7RC1]# mkdir /etc/vsftpd/conf.d/
[root@centos79 pam_mysql-0.7RC1]# cat /etc/vsftpd/conf.d/user01
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable第十四,十五周作业

第十五周java作业

第十五周作业

第十五周作业

第十五周作业

Java第十五周作业