Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 230

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 300

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 301

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 302

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 305

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 308

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 311

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320
VSFTP+MySQL虚拟用户配置 – 理想社会

VSFTP+MySQL虚拟用户配置

V

VSFTP+MySQL虚拟用户配置

1、 安装vsftp软件

下载vsftp(最新版本)软件: wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.1.0.tar.gz

如果要开始ssl功能的话,安装vsftp之前要先安装openssl-0.9.8g.tar.gz包

[root@server2 ftp]# tar xzvf openssl-0.9.8g.tar.gz

[root@server2 ftp]# cd openssl-0.9.8g

[root@server2 openssl-0.9.8g]# ./config

[root@server2 openssl-0.9.8g]# make && make install

安装vsftp:

[root@server2 ftp]# tar xzvf vsftpd-2.1.0.tar.gz

[root@server2 ftp]# cd vsftpd-2.1.0

[root@server2 vsftpd-2.1.0]# vi builddefs.h

#ifndef VSF_BUILDDEFS_H

#define VSF_BUILDDEFS_H

#undef VSF_BUILD_TCPWRAPPERS

#define VSF_BUILD_PAM

#undef VSF_BUILD_SSL

#endif /* VSF_BUILDDEFS_H */

把undef都更改成define,支持tcp_wrappers,支持PAM认证方式,支持SSL

不知道为什么用2.10.0版本的时候make的时候老是出现:

ssl.o(.text+0x760): In function `ssl_cert_digest’:
: undefined reference to `EVP_sha256′
collect2: ld returned 1 exit status
make: *** [vsftpd] Error 1

所以换成2.0.3版本!

[root@server2 vsftpd-2.0.3]# make

[root@server2 vsftpd-2.0.3]# ls -l vsftpd

-rwxr-xr-x  1 root root 85932 Mar 23 14:53 vsftpd  //可执行程序安装成功

创建必要的帐号,目录:
# useradd nobody  //可能你的系统已经存在此帐号,那就不用建立
# mkdir /usr/share/empty  //可能你的系统 已经存在此目录,那就不用建立
# mkdir /var/ftp  //可能你的系统已经存在此目录, 那就不用建立
# useradd -d /var/ftp ftp  //可能你的系 统已经存在此帐号,那就不用建立
# chown root:root /var/ftp
# chmod og-w /var/ftp
请记 住,如果你不想让用户在本地登陆,那么你需要把他的登陆SHELL设置成/sbin/nologin,比如以上的nobody和ftp我就设置成/sbin/nologin

安装vsftp配置文件,可执行程序,man等:
# install -m 755 vsftpd /usr/local/sbin/vsftpd
# install -m 644 vsftpd.8 /usr/share/man/man8
# install -m 644 vsftpd.conf.5 /usr/share/man/man5
# install -m 644 vsftpd.conf /etc/vsftpd.conf

这样vsftp的安装就完成了

2、  安装mysql数据库,并进行相关的设置

Mysql的安装就不说了,这里只说明对mysql数据库的相关操作:

(1)       建立一个库并设置相应权限

[root@server2 vsftpd-2.0.3]# mysql –uroot

mysql>create database ftpd;
mysql>use ftpd;
mysql>create table user(name char(20) binary,passwd char(20) binary);
mysql>insert into user (name,passwd) values (‘zhang1′,’123456’);
mysql>insert into user (name,passwd) values (‘zhang2′,’654321’);
mysql>grant select on ftpd.user to ftpd@localhost identified by ‘123456’;
mysql>flush privileges; 刷新权限设置
mysql>quit

(2)       测试ftpd对数据库的权限是否OK!

3、  下载、安装、编译pam-mysql

http://nchc.dl.sourceforge.net/sourceforge/pam-mysql/pam_mysql-0.5.tar.gz

[root@server2 ftp]# tar xzvf pam_mysql-0.5.tar.gz

[root@server2 ftp]# cd pam_mysql

[root@server2 pam_mysql]# cp pam_mysql.so  /lib/security/

4、  建立PAM认证信息

vi /etc/pam.d/ftp ,内容如下
auth required /lib/security/pam_mysql.so user=ftpd passwd=123456 host=localhost db=ftpd table=user usercolumn=name passwdcolumn=passwd crypt=0

account required /lib/security/pam_mysql.so user=ftpd passwd=123456 host=localhost db=ftpd table=user usercolumn=name passwdcolumn=passwd crypt=0

注意:
crypt= n
crypt=0: 明文密码
crypt=1: 使用crpyt()函数(对应SQL数据里的encrypt(),encrypt()随机产生salt)
crypt=2: 使用MYSQL中的password()函数加密
crypt=3:表示使用md5的散列方式

5、  建立本地虚拟用户:

useradd -d /home/ftpd -s /sbin/nologin ftpd

6、  修改配置文件:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
chroot_local_user=YES
guest_enable=YES
guest_username=ftpd
listen=YES
listen_port=21
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30999
anon_world_readable_only=NO
virtual_use_local_privs=YES

7、  启动vsftpd

/usr/local/sbin/vsftpd /etc/vsftpd.conf &  //后台运行!

8、  Test

[root@server2 vsftpd-2.0.3]# ftp 127.0.0.1

Connected to 127.0.0.1.

220 (vsFTPd 2.0.3)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (127.0.0.1:root): zhang1

331 Please specify the password.

Password:

230 Login successful.    \已经登录成功了!

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> quit

221 Goodbye.

About the author

Add comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

By now163

Your sidebar area is currently empty. Hurry up and add some widgets.