search
HomeDatabaseMysql Tutorialvsftpd+pam+mysql服务器的实现_MySQL

一、vsftpd服务器端的安装:

   yum install vsftpd

   查看安装后生成的哪些文件

[root@station113 ~]# rpm -ql vsftpd

/etc/logrotate.d/vsftpd  

/etc/pam.d/vsftpd《==================认证文件

/etc/rc.d/init.d/vsftpd《=============服务脚本

/etc/vsftpd《=========================程序的配置文件

/etc/vsftpd/ftpusers《=========

/etc/vsftpd/user_list《==================控制用户访问的

/etc/vsftpd/vsftpd.conf《================主配置文件

/etc/vsftpd/vsftpd_conf_migrate.sh

/var/ftp《===============================服务器文件存放目录

/var/ftp/pub《===========================服务器上共享文件的存放位置


启动服务

   [root@station113 ~]# service vsftpd start

    Starting vsftpd for vsftpd:                                [  OK  ]

查看启动装态

    [root@station113 ~]# ps aux | grep vsftpd

root      5200  0.0  0.0  52524   788 ?        Ss   22:55   0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

root      5207  0.0  0.0 103252   836 pts/0    S+   22:56   0:00 grep vsftpd


[root@station113 ~]# ss -tnl《======查看一下21号端口是否启用起来了

State      Recv-Q Send-Q                         Local Address:Port                           Peer Address:Port

LISTEN     0      128                                       :::111                                      :::*    

LISTEN     0      128                                        *:111                                       *:*    

LISTEN     0      32                                         *:21                                   *:*    

LISTEN     0      128                                       :::22                                       :::*    

LISTEN     0      128                                        *:22                                        *:*    

LISTEN     0    



二、服务器端配置


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


anonymous_enable=YES《====启用匿名用户

local_enable=YES《=========充许本地用户访问

write_enable=YES《=========是否允许上传文件

anon_upload_enable=YES《====匿名用启上传

anon_mkdir_write_enable=YES《=匿名用户创建目录

anon_other_write_enable=YES《==匿名用户有写权限




定义欢迎信息

banner_file=/path/to/some_banner_file

ftp_banner=some string

dirmessage_enable=yes

在某ftp可访问的目录下创建.messages文件

# You may fully customise the login banner string:

#ftpd_banner=Welcome to blah FTP service.

#

# You may specify a file of disallowed anonymous e-mail addresses. Apparently

# useful for combatting certain DoS attacks.

#deny_email_enable=YES

# (default follows)

#banned_email_file=/etc/vsftpd/banned_emails




vsftp控制登录用户的机制:

/etc/vsftpd/ftpusers中的用户都不允许使用ftp服务, 这是在/etc/pam.d/vsftpd中定义;


user_list配置文件有两种用法:

黑名单:

userlist_enable=YES

userlist_deny=YES

白名单

userlist_enable=YES

userlist_deny=NO

写在下面的目录中的用户都不允许登陆

[root@station113 ~]# cd /etc/vsftpd/

[root@station113 vsftpd]# ls

chroot_list  ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

[root@station113 vsftpd]# cat ftpusers

# Users that are not allowed to login via ftp

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

[root@station113 vsftpd]# echo opentow >> ftpusers

[root@station113 vsftpd]# cat frpusers


pam安装

root@www ~]# tar xf pam_mysql-0.7RC1.tar.gz

[root@www ~]# cd pam_mysql-0.7RC1

[root@www pam_mysql-0.7RC1]# ./configure --with-mysql=/usr/local/mysql --with-openssl

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

[root@www pam_mysql-0.7RC1]# ls -l /lib/security/

total 124

-rwxr-xr-x 1 root root    885 Mar 26 18:23 pam_mysql.la

-rwxr-xr-x 1 root root 119100 Mar 26 18:23 pam_mysql.so

[root@www pam_mysql-0.7RC1]# ln -sv /lib/security/pam_mysql.so /lib64/security/

`/lib64/security/pam_mysql.so' -> `/lib/security/pam_mysql.so'

安装mysql服务器端

[root@www ~]# yum install mysql-sercer mysql-sever mysql-devel pam-mysql

[root@www ~]service mysqld start

登陆mysql

[root@www ~]# mysql


mysql> CREATE DATABASE vsftpd;

Query OK, 1 row affected (0.00 sec)


mysql> GRANT ALL ON vsftpd.* TO 'vsftpd'@'172.16.%,%'IDENTIFIED BY 'vsftpd';

Query OK, 0 rows affected (0.01 sec)


mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

mysql> /q

Bye


验证一下是否能够登陆

[root@www ~]# mysql -uvsftpd -h172.16.24.8 -pvsftpd


Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 13

Server version: 5.5.33-log MySQL Community Server (GPL)


Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.



mysql> SHOW DATABASES;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| test               |

| vsftpd             |

+--------------------+

3 rows in set (0.03 sec)


mysql> CREATE TABLE users (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,name VARCHAR(50) NOT NULL, password CHAR(48) NOT NULL);

Query OK, 0 rows affected (0.01 sec)


mysql> DESC users;

+----------+------------------+------+-----+---------+----------------+

| Field    | Type             | Null | Key | Default | Extra          |

+----------+------------------+------+-----+---------+----------------+

| id       | int(10) unsigned | NO   | PRI | NULL    | auto_increment |

| name     | varchar(50)      | NO   |     | NULL    |                |

| password | char(48)         | NO   |     | NULL    |                |

+----------+------------------+------+-----+---------+----------------+

3 rows in set (0.04 sec)



mysql> INSERT INTO users (name,password) VALUES ('tom','toms'),('jerry','jerrys');《====创建两个用户tom 和jerry;

Query OK, 2 rows affected (0.00 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> /q

Bye



配置vsftpd

[root@www ~]# vim /etc/pam.d/vsftpd.mysql

auth required /lib/security/pam_mysql.so user=vsftpd passwd=vsftpd host=172.16.24.8 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=0

account required /lib/security/pam_mysql.so user=vsftpd passwd=vsftpd host=172.16.24.8 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=0


以上请写你自己的地址。

~                                                                                          

注意:由于mysql的安装方式不同,pam_mysql.so基于unix sock连接mysql服务器时可能会出问题,此时,建议授权一个可远程连接的mysql并访问vsftpd数据库的用户。


.修改vsftpd的配置文件,使其适应mysql认证


建立虚拟用户映射的系统用户及对应的目录


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

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


请确保/etc/vsftpd.conf中已经启用了以下选项

anonymous_enable=YES《========启动匿名用户

local_enable=YES

write_enable=YES

anon_upload_enable=NO

anon_mkdir_write_enable=NO

chroot_local_user=YES



[root@www ~]# cd /etc/vsftpd

[root@www vsftpd]# vim vsftpd.conf


而后添加以下选项

guest_enable=YES

guest_username=vuser


并确保pam_service_name选项的值如下所示

pam_service_name=vsftpd.mysql





[root@www ~]# service vsftpd reload

Shutting down vsftpd:                                      [  OK  ]

Starting vsftpd for vsftpd:                                [  OK  ]

[root@www ~]#


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the role of InnoDB redo logs and undo logs.Explain the role of InnoDB redo logs and undo logs.Apr 15, 2025 am 12:16 AM

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?Apr 15, 2025 am 12:15 AM

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

What is the Using temporary status in EXPLAIN and how to avoid it?What is the Using temporary status in EXPLAIN and how to avoid it?Apr 15, 2025 am 12:14 AM

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Apr 15, 2025 am 12:11 AM

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL vs. Other Databases: Comparing the OptionsMySQL vs. Other Databases: Comparing the OptionsApr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool