ºìÁªLinuxÃÅ»§
Linux°ïÖú
µ±Ç°Î»ÖÃ: ºìÁªLinuxÃÅ»§ > Debian

Debian LinuxÏÂvsftpd+mysqlÐéÄâÓû§×÷·¨

·¢²¼Ê±¼ä:2007-10-16 00:27:52À´Ô´:ºìÁª×÷Õß:Mqqlecyro
½ñÌìÏÐÀ´ÎÞÊÂ×öÁ˸öftp£¬Ô­ÒòºÜ¼òµ¥¾ÍÊÇΪÁËÄÜÔڱ𴦿´µ½µÄºÃ¶«Î÷Ö±½Ó·Åµ½ÎҵĻúÆ÷ÉÏ£¬ºÙ ºÙ£¡linuxÏÂÑ¡Ôñftp·þÎñÆ÷»¹ÕæÊDz»ÈÝÒ×£¬¾­¹ýÒ»Õó˼Ë÷ºó¾ÍÑ¡ÔñÁËvsftpd£¬ÀíÓɾÍÊÇËüºÅ³ÆÊÇlinuxÏÂ×ȫµÄftp·þÎñÆ÷»¹Óл¹ÓкöàµÄ ´óÐÍÕ¾µã¶¼ÓÃËüÀ´×ö·þÎñÆ÷(ÕâÑùÓÃÆðÀ´Ò²±È½ÏÓÐÃæ×Ó ¡£ÎªÁËÅÂÔÚÎÒÊäÈëÃÜÂëʱ±»±ðÈË͵¿´µ½È»ºóµÇÈëÎÒ»úÆ÷ÂҸ㣬ÔÚ¼ÓÉÏÎÒ±¾À´¾ÍÌÖÑáϵͳÓÐÄÇô¶àµÄÓû§ (ÆäʵҲÊÇÏñÏÔʾ×Ô¼ºµÄÊÖƽ)£¬ËùÒÔÎÒ¾ö¶¨²ÉÓÃÐéÄâÓû§£¬ÒòΪ»úÆ÷ÖÐ×°ÓÐMysql£¬ÓÚÊÇÎÒ¾ÍÏ뽫ÐéÄâÓû§Êý¾Ý·ÅÔÚmysqlÖУ¬ºÃÁË£¬¾ÍÙ©µ½ÕâÀÏÂÃæ ½øÈëÕýÌ⣡

µÚÒ»²½£º

°²×°vsftpd

apt-get install vsftpd (Debian¾ÍÊÇˬ°¡£¡)

ϵͳ»á×Ô¶¯Éú³ÉÒ»¸öÅäÖÃÎļþºÍÒ»¸öftpÓû§¹©ÄäÃûÓû§Ê¹ÓÃ,vsftpdʹÓÃPAM·½Ê½À´ÑéÖ¤ÐéÄâÓû§£¬ÒòΪÐéÄâÓû§µÄÐÅÏ¢±£´æÔÚÊý¾Ý¿âÖУ¬ËùÒÔÎÒÃÇ»¹ÐèÒªÒ»¸öÄܹ»¶ÁÈ¡Êý¾Ý¿âÄÚÈݵı¾µØÓû§,¶øÇÒ»¹ÐèÒªÉèÖÃËüµÄ±¾µØĿ¼£º

#mkdir /var/ftp

#useradd -d ftpguest /var/ftp

#chown ftpguest.nogroup /var/ftp

µÚ¶þ²½£º°²×°mysql

apt-get install mysql-server mysql-clent

½¨Á¢Êý¾Ý¿â£¬²¢Ìí¼ÓÓû§

#mysql -p mysql>create ftpu;

mysql>use ftpu;

mysql>create table user(name char(20) binary,passwd char(20) binary);

mysql>insert into user (name,passwd) values ('test1',password('1234567'));

mysql>insert into user (name,passwd) values ('test2',password('7654321'));

mysql>quit

ÈÃftpguestÄÜ·ÃÎÊftpuºÍ±íuser:

#mysql -u root mysql -p mysql>grant select on ftpu.user to ftpguest@localhost identified by '123456';

mysql>quit

µÚÈý²½£ºÒòΪvsftpdÊÇͨ¹ýPAMÑéÖ¤£¬ËùÒÔÎÒÃÇ»¹ÐèÒªÒ»¸ömysqlͨ¹ýPAMÑéÖ¤µÄ°ü,ÔÚDebianÏÂËü½Ð×ölibpam-mysql

apt-get install libpam-mysql

È»ºó´ò¿ªvsftpdµÄPAMÑéÖ¤:

#vi /etc/pam.d/vsftpd

½«ÒÔÇ°µÄÄÚÈÝ×¢Ê͵ô£¬È»ºó¼ÓÈëÒÔÏÂÄÚÈÝ£º

auth required pam_mysql.so user=ftpguest passwd=123456 host=localhost db=ftpu table=user usercolumn=name passwdcolumn=passwd crypt=2

account required pam_mysql.so user=ftpguest passwd=123456 host=localhost db=ftpu table=user usercolumn=name passwdcolumn=passwd crypt=2

ÉÏÃæµÄÄÚÈÝÓ¦¸ÃÄÜ¿´Ã÷°×°É£¬ÄǸöcrypt=2±íʾ¾­¹ýmysqlµÄpassword()»úÃܺóµÄ¶«Î÷£¡

µÚËIJ½£ºÐÞ¸Ävsftpd.confÎļþ

#vi /etc/vsftpd.conf

¼ÓÈë:

uest_enable=YES

guest_username=ftpguest

#±íʾftpguestΪvsftpµÄÐéÄâÓû§

virtual_use_local_privs=YES

#ÐéÄâÓû§Óë±¾µØÓû§ÓÐÏàͬµÄȨÏÞ

write_enable=YES

anon_upload_enable=YES

anon_other_write_enable=YES

#ÔÊÐíÐéÄâÓû§ÉÏ´«£¬Ð޸ĺÍɾ³ýÎļþ

chroot_local_user=YES

#ÐéÄâÓû§Ö»ÄÜ·ÃÎÊ×Ô¼ºµÄĿ¼

anonymous_enable=NO

local_enable=YES

#¹Ø±ÕÄäÃûÓû§·ÃÎÊ£¬¿ªÆô±¾µØÓû§·ÃÎÊ

µÚÎå²½:

±¾À´À´µ½µÚËIJ½ÒѾ­Íê³ÉÁË£¬¿ÉÊǺóÀ´Ò»Ï룬²»¶Ô£¬ÄÇÒªÊÇÿ´ÎÉÏ´«µÄ¶«Î÷¶¼²»Í¬£¬µ½Ê±°ÑÄǸöĿ¼ŪµÃÂÒÆß°ËÔãµÄÔõô¹ÜÀí°¡£¬Äܲ»ÄÜΪÿ¸öÐéÄâÓû§´´½¨Ò»¸öĿ¼ÄØ£¬±ÈÈç˵½«musicÓû§ÉÏ´«µÄÎļþ·ÅÔÚ·ÅÔÚ~/musicÏ£¬½«docÓû§ÉÏ´«µÄÎļþ·ÅÔÚ~/docÏÂÄØ£¿

ÄÜ£¡µ±È»ÄÜÁË£¬¿´¿´ÎÒÔõô×ö£¿

Ê×ÏÈÔÚÊý¾Ý¿âÖÐÌí¼ÓmusicºÍdocÁ½¸öÐéÄâÓû§½ÓÏÂÀ´£º

#mkdir /etc/vsftpd_user_conf

#cd /etc/vsftpd_user_conf

#touch music

#echo "local_root=/home/username/music" > music

#touch doc

#echo "local_root=/home/username/doc" > doc

#mkdir /home/username/music

#chown ftpguest.nogroup /home/username/music

#chmod 600 /home/username/music

#chown ftpguest.nogroup /home/username/doc

#chmod 600 /home/username/doc

È»ºóÔÚvsftpd.confÖмÓÈ룺 user_config_dir=/etc/vsftpd_user_conf
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ