CentOS下配置vsftpd
创始人
2024-07-21 13:00:54
0

  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常用功能之限速和限制链接点

 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...
2012年第四季度互联网状况报... [[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...