CentOS下配置vsftpd

运维 系统运维
CentOS下配置vsftpd还是比较常用的,这里所讲解介绍centos vsftpd的安装。CentOS Linux与RHEL产品有着严格的版本对应关系。那么该如何在CentOS下配置vsftpd?本章将一一简述,CentOS下配置vsftpd

  1、通过YUM安装必需的vsftpd, pam, pam-devel;

  2、通过编译安装必需的pam_mysql(下面附件里);

  3、修改默认vsftpd配置文件 (/etc/vsftpd/vsftpd.conf)以及添加ftp用户的权限配置文件(/etc/vsftpd/vconf/);

  4、添加虚拟系统用户,及其ftp用户登录认证数据库;

  5、修改vsftpd默认的pam配置文件 (/etc/pam.d/vsftpd);

  6、添加ftp端口到防火墙,重启vsftpd服务,测试ftp虚拟用户登录。

  1)

  1.   [simonsun@magic ~]$ sudo yum install vsftpd pam pam-devel  
  2.  

  目前的版本为

  vsftpd - 2.0.5-12.el5, pam - 0.99.6.2-3.27.el5, pam-devel - 0.99.6.2-3.27.el5。

  2)

  1.   [simonsun@magic ~]$ wget http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz  
  2.  
  3.   [simonsun@magic ~]$ tar zxvf pam_mysql-0.7RC1.tar.gz  
  4.  
  5.   [simonsun@magic ~]$ ls pam_mysql-0.7RC1  
  6.  
  7.   acinclude.m4 config.guess configure CREDITS ltmain.sh missing pam_mysql.c pkg.m4  
  8.  
  9.   aclocal.m4 config.h.in configure.in INSTALL Makefile.am mkinstalldirs pam_mysql.spec README  
  10.  
  11.   ChangeLog config.sub COPYING install-sh Makefile.in NEWS pam_mysql.spec.in stamp-h.in  
  12.  
  13.   [simonsun@magic ~]$ vim pam_mysql-0.7RC1/configure  
  14.  

  #修改configure中的一个bug,将下面的一段修改,加上#include ,原来没有此引用。

  =================================

  1.   #include   
  2.  
  3.   #include   
  4.  
  5.   int  
  6.  
  7.   main ()  
  8.  
  9.   {  
  10.  
  11.   md5_calc(0, 0, 0);  
  12.  
  13.   ;  
  14.  
  15.   return 0;  
  16.  
  17.   }  
  18.  

  =================================

  1.   [simonsun@magic ~]$ cd pam_mysql-0.7RC1  
  2.  
  3.   [simonsun@magic pam_mysql-0.7RC1]$ ./configure  
  4.  
  5.   [simonsun@magic pam_mysql-0.7RC1]$ make  
  6.  
  7.   [simonsun@magic pam_mysql-0.7RC1]$ sudo make install  
  8.  
  9.   [simonsun@magic pam_mysql-0.7RC1]$ sudo cp /usr/lib/security/pam_mysql.* /lib/security/  
  10.  

  3)

 

  1.   [simonsun@magic ~]$ sudo vim /etc/vsftpd/vsftpd.conf  
  2.  

  ======================================

  1.   anonymous_enable=NO 
  2.  
  3.   local_enable=YES 
  4.  
  5.   write_enable=YES 
  6.  
  7.   local_umask=022 
  8.  
  9.   #anon_upload_enable=YES 
  10.  
  11.   #anon_mkdir_write_enable=YES 
  12.  
  13.   dirmessage_enable=YES 
  14.  
  15.   xferlog_enable=YES 
  16.  
  17.   connect_from_port_20=YES 
  18.  
  19.   #chown_uploads=YES 
  20.  
  21.   #chown_username=whoever 
  22.  
  23.   xferlog_file=/var/log/vsftpd.log  
  24.  
  25.   xferlog_std_format=YES 
  26.  
  27.   #idle_session_timeout=600 
  28.  
  29.   #data_connection_timeout=120 
  30.  
  31.   #nopriv_user=ftpsecure 
  32.  
  33.   #async_abor_enable=YES 
  34.  
  35.   #ascii_upload_enable=YES 
  36.  
  37.   #ascii_download_enable=YES 
  38.  
  39.   ftpd_banner=Welcome to Magic Linux FTP service.  
  40.  
  41.   #deny_email_enable=YES 
  42.  
  43.   # (default follows)  
  44.  
  45.   #banned_email_file=/etc/vsftpd/banned_emails  
  46.  
  47.   chroot_local_user=YES 
  48.  
  49.   #chroot_list_enable=YES 
  50.  
  51.   # (default follows)  
  52.  
  53.   #chroot_list_file=/etc/vsftpd/chroot_list  
  54.  
  55.   #ls_recurse_enable=YES 
  56.  
  57.   listen=YES 
  58.  
  59.   listen_port=21 
  60.  
  61.   #listen_ipv6=YES 
  62.  

  #下面是添加的:

 

  1.   guest_enable=YES 
  2.  
  3.   guest_username=vvsftpd #虚拟系统用户,在步骤4)中添加该用户到系统用户中。  
  4.  
  5.   user_config_dir=/etc/vsftpd/vconf/ #登录ftp的虚拟用户的权限配置文件。  
  6.  
  7.   pam_service_name=vsftpd 
  8.  
  9.   userlist_enable=YES 
  10.  
  11.   tcp_wrappers=YES 
  12.  

  ======================================

  1.   [simonsun@magic ~]$ sudo mkdir /etc/vsftpd/vconf/  
  2.  
  3.   [simonsun@magic ~]$ sudo vim /etc/vsftpd/vconf/myftp  
  4.  

  ======================================

  1.   write_enable=YES 
  2.  
  3.   anon_upload_enable=YES 
  4.  
  5.   anon_mkdir_write_enable=YES 
  6.  
  7.   anon_world_readable_only=NO 
  8.  

  ======================================

  4)

  1.   [simonsun@magic ~]$ sudo /usr/sbin/useradd -d /home/vvsftpd -s /sbin/nologin vvsftpd  
  2.  
  3.   [simonsun@magic ~]$ mysql -u root -p  
  4.  

  #执行如下语句,为虚拟系统用户vvsftpd创建虚拟用户(如myftp)登录ftp时的认证数据库vsftpd

  1.   ======================================  
  2.  
  3.   create database vsftpd;  
  4.  
  5.   use vsftpd;  
  6.  
  7.   create table user(name char(20) binary,passwd char(20) binary);  
  8.  
  9.   insert into user values ('myftp',ENCRYPT('ptfym'));  
  10.  
  11.   grant select on vsftpd.user to vvsftpd@localhost identified by 'PaSsWoRd';  
  12.  
  13.   flush privileges;  
  14.  
  15.   ======================================  
  16.  

  5)

  1.   [simonsun@magic ~]$ sudo vim /etc/pam.d/vsftpd  
  2.  

  修改成如下

  1.   ======================================  
  2.  
  3.   #%PAM-1.0  
  4.  
  5.   session optional pam_keyinit.so force revoke  
  6.  
  7.   auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers nerr=succeed 
  8.  
  9.   #auth required pam_shells.so  
  10.  
  11.   auth required /lib/security/pam_mysql.so user=vvsftpd passwd=PaSsWoRd host=localhost db=vsftpd table=user usercolumn=name passwdpasswdcolumn=passwd crypt=1 
  12.  
  13.   account required /lib/security/pam_mysql.so user=vvsftpd passwd=PaSsWoRd host=localhost db=vsftpd table=user usercolumn=name passwdpasswdcolumn=passwd crypt=1 
  14.  
  15.   #auth include system-auth  
  16.  
  17.   #account include system-auth  
  18.  
  19.   session include system-auth  
  20.  
  21.   session required pam_loginuid.so  
  22.  
  23.   ======================================  
  24.  

  6)

  1.   [simonsun@magic ~]$ sudo /sbin/iptables -I INPUT -p tcp --dport 20 -j ACCEPT  
  2.  
  3.   [simonsun@magic ~]$ sudo /sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT  
  4.  
  5.   [simonsun@magic ~]$ sudo /etc/rc.d/init.d/iptables save  
  6.  
  7.   [simonsun@magic ~]$ sudo /etc/rc.d/init.d/iptables restart  
  8.  

  清除防火墙规则: [确定]

  把 chains 设置为 ACCEPT 策略:filter nat [确定]

  正在卸载 Iiptables 模块: [确定]

  应用 iptables 防火墙规则: [确定]

  载入额外 iptables 模块:ip_conntrack_netbios_ns [确定]

  1.   [simonsun@magic ~]$ sudo /etc/rc.d/init.d/vsftpd restart  
  2.  

  关闭 vsftpd: [确定]

  为 vsftpd 启动 vsftpd: [确定]

  1.   [simonsun@magic ~]$ ftp shellfisher.3322.org  
  2.  
  3.   Connected to shellfisher.3322.org.  
  4.  
  5.   220 Welcome to Magic Linux FTP service.  
  6.  
  7.   530 Please login with USER and PASS.  
  8.  
  9.   530 Please login with USER and PASS.  
  10.  
  11.   KERBEROS_V4 rejected as an authentication type  
  12.  
  13.   Name (shellfisher.3322.org:simonsun): myftp  
  14.  
  15.   331 Please specify the password.  
  16.  
  17.   Password:  
  18.  
  19.   230 Login successful.  
  20.  
  21.   Remote system type is UNIX.  
  22.  
  23.   Using binary mode to transfer files.  
  24.  
  25.   ftp> ls  
  26.  
  27.   227 Entering Passive Mode (221,215,250,110,86,88)  
  28.  
  29.   150 Here comes the directory listing.  
  30.  
  31.   226 Directory send OK.  
  32.  
  33.   ftp> mkdir testftp  
  34.  
  35.   257 "/testftp" created  
  36.  
  37.   ftp> ls  
  38.  
  39.   227 Entering Passive Mode (221,215,250,110,43,155)  
  40.  
  41.   150 Here comes the directory listing.  
  42.  
  43.   drwx------ 2 507 509 4096 Mar 24 08:32 testftp  
  44.  
  45.   226 Directory send OK.  
  46.  
  47.   ftp> quit  
  48.  
  49.   221 Goodbye.  
  50.  
  51.   ======================================  
  52.  

【编辑推荐】

  1. Linux下vsftp服务器配置
  2. vsFTPd服务器的启动和关闭
  3. 怎样安装vsFTPd
  4. Linux下配置vsftpd
  5. vsftpd安装篇
  6. vsftpd 启动篇
  7. Linux下vsftpd的配置
  8. 如果SELinux拒绝vsftpd上传文件到用户主目录怎么办
  9. vsFTPd常用功能之限速和限制链接点

 

责任编辑:zhaolei 来源: 网络转载
相关推荐

2011-02-23 09:55:33

Centos安装vsftpd

2011-03-02 09:52:03

2011-02-23 15:50:04

Linuxvsftpd

2011-02-23 17:23:35

linux vsftpd

2011-02-23 15:50:04

Linuxvsftpd

2011-03-01 09:44:04

ubuntuvsftpd

2011-03-02 13:23:42

Vsftpd配置

2011-03-07 09:11:31

Vsftpd档案

2011-02-22 13:28:43

Linuxvsftpd配置

2010-02-22 18:27:14

CentOS vsft

2010-01-13 13:50:53

CentOS Vsft

2010-02-22 18:12:25

CentOS vsft

2010-12-27 13:26:25

FreeBSDvsftpd虚拟用户

2011-03-07 09:37:32

Vsftpd启动CentOS

2010-01-13 14:45:25

CentOS配置

2010-02-22 17:45:50

CentOS VSFT

2010-01-13 13:27:07

CentOS vsft

2011-03-02 11:32:55

vsftpd配置

2010-01-15 17:35:09

2010-01-11 14:46:41

vsftpd配置
点赞
收藏

51CTO技术栈公众号