Home Database Mysql Tutorial vsftpd+pam+mysql服务器的实现_MySQL

vsftpd+pam+mysql服务器的实现_MySQL

Jun 01, 2016 pm 01:10 PM

一、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 of this Website
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

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

See all articles