ÓÃÒ»ÌìµÄʱ¼äÑо¿ÁËLinuxϵÄftpÈí¼þ vsftp,ÍêÍêÕûÕûµÄ´î½¨ÁËÒ»¸öÍêÈ«¼òµ¥µÄftp·þÎñÆ÷£¬×ö¸ö×ܽᡣvsftpd ÊÇÒ»¸öºÜºÃµÄFTP·þÎñÆ÷Èí¼þ£¬vsftpdÔÚ°²È«ÐÔ·½Ã棬Ö÷ÒªÕë¶Ô³ÌÐòµÄȨÏÞ£¨privilege£©À´Éè¼Æ
Á½ÕŰ²È«´ëÊ©£º
1£ºÍ¨¹ý½µµÍµÇ½FTP·þÎñÆ÷µÄpidµÄȨÏÞ£¬Ê¹ÈëÇÖÕßÎÞ·¨µÃµ½ÓÐЧµÄ¹ÜÀíȨÏÞ£¬ÕâÑùÎÒÃǵÄϵͳ¾Í½ÏΪ°²È«¡£
2£º vsftpdÀûÓÃÁËchrootÈí¼þ£¬ÈÃÓû§½öÄÜÔÚһЩ²»ÖØÒªµÄĿ¼»î¶¯£¬¶øÎÞ·¨Ê¹ÓÃLINUXµÄϵͳµÄÈ«²¿¹¦ÄÜ£¬chrootÖ÷ÒªÊǸıä¸ùĿ¼µÄλÖã¬ÀýÈçÄãÏëÈÃÓû§µÇ½A·þÎñ£¬ÇÒÖ´ÐÐÈκÎÖ¸Áî¶¼ÊÇÔÚ/tmp/pubĿ¼Ï£¬²¢ÏÞÖÆÓû§Ê¹ÓÃA·þÎñʱֻÄÜÔÚ/tmp/pubĿ¼Ï£¬ÄÇôʹÓÃchroot /tmp/pub commend¾ÍÄÜÈÃ/tmp/pub±ä³ÉA·þÎñµÄ¸ùĿ¼ /,ÕâÑùÓû§²»ÄÜÍ˳ö/tmp/pub£¬Óû§Ö»ÄÜÔÚ±¾Ä¿Â¼»î¶¯¡£
vsftpdͨ¹ýtar,make,make install °²×°µÄ»°£¬Ä¬ÈÏ»áËæxinetd£¨³¬¼¶·þÎñÆ÷£©Ò»ÆðÆô¶¯£¬¾ÍÊǷǶÀÁ¢Ä£Ê½Æô¶¯£¬ÐèÒªÐ޸IJÅÄܶÀÁ¢Ä£Ê½Æô¶¯¡£
#½âѹ
tar -zxf vsftpd-2.0.5.tar.gz
cd ../vsftpd-2.0.5
#vsftpdÐèҪʹÓÃnobodyÀ´×÷ΪÔËÐÐÕß,Ò»°ãÒѾ´æÔÚ£¬Èç¹ûûÓÐÌí¼ÓÓû§
useradd nobody
#°²×°Ê±ÐèÒª/usr/share/empty/
×÷ΪÁÙʱĿ¼,Ò»°ãÒѾ´æÔÚ£¬Èç¹ûûÓУ¬Í¨¹ýÏÂÃæÃüÁî´´½¨
mkdir -pv /usr/share/empty/
#±àÒë
make
make install
#Èç¹ûmake installûÓа²×°Îļþ,Äã¿ÉÒÔÊÖ¶¯Ö´ÐÐÏÂÃæµÄÃüÁî
cp vsftpd /usr/local/sbin/vsftpd
cp vsftpd.conf /etc/vsftpd.conf
cp vsftpd.conf.5 /usr/local/man/man5
cp vsftpd.8 /usr/local/man/man8
cp vsftpd.xinetd /etc/xinetd.d/vsftpd
#ÖØÆô xinetd ·þÎñ
/etc/rc.d/init.d/xinetd restart
ÒòΪÊÇ×Ô¼º±àÒë°²×°µÄ£¬ËùÒÔÒªÔÚ/etc/xinetd.d/vsftpd ÀïÈ·ÈÏ disable=YES
Èç¹û¸ÄΪ NO ÔÙÅäºÏ vsftpd.confÀïµÄ listen=YES vsftpd¾Í¿ÉÒÔµ¥Óû§Ä£Ê½Æô¶¯¡£
»á³öÏֵĴíÎó£º
500 OOPS: could not bind listening IPv4 socket
1£ºxinetd ÒѾÆô¶¯ÁË£¬¶øVSFTPDÉèÖóÉÁ˵¥Óû§Ä£Ê½ËùÒÔÒªÏÈÍ£µôxinetdµÄ·þÎñ¡£
service xinetd stop È»ºó /usr/local/sbin/vsftpd /etc/vsftpd &
2: vsftpd.confÀïµÄ¼àÌý¶Ë¿Ú´íÎó£¬Ä¬ÈÏÓ¦¸ÃΪ21£¬Èç¹û¸Ã³ÉÆäËûµÄ£¬Èç
listen_port=2121 µÇ½ftp¾ÍÓ¦¸ÃΪ ftp 127.0.0.1 2121¡£
ÓÃtarÃüÁî°²×°³õʼ°²×°²½Öè×ܽáһϡ£
1.ÏÂvsftpd-2.0.5.tar.gz
2.Ð¶ÔØÔÓеÄrpmµÄvsftpd
rpm -e vsftpd
3.tar xvzf vsftpd-2.0.5.tar.gz
4.cd vsftpd-2.0.5
5.maka
6.useradd nobody
7.mkdir /usr/share/empty
8.mkdir /var/ftp
9.useradd -d /var/ftp ftp
10.chown root.root /var/ftp
11.chmod og-w /var/ftp
12. make install
13.vi /etc/xinetd.d/vsftpd
°Ñdisable=yes¸Ä³Éno£¬±£´æÍ˳ö¡£È»ºóservice xinetd restart£¬OK£¡ÐÂ×°µÄvsftpÒѾ¿ÉÒÔ¹¤
×÷ÁË£¡
####### ÅäÖÃÎļþ#########
ÒÔÏÂÊÇÎÒÅäÖÃÎĵµÀïÃæµÄÄÚÈÝ
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES #ÔÊÐíÄäÃûµÇ¼
#
# Uncomment this to allow local users to log in.
local_enable=YES #ÔÊÐí±¾µØÓû§µÇ¼
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES #ÔÊÐíÈκÎÐÎʽµÄFTPдÃüÁî
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022 #ĬÈϱ¾µØÓû§µÄumaskÊÇ077,Äã¿ÉÄÜÏë¸Ä³É022,Èç¹ûÄãµÄÓû§ÆÚÅÎÄÇÑù
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES #ÔÊÐíÄäÃûÓû§ÉÏ´«Îļþ
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES #ÔÊÐíÄäÃûftpÓû§Óн¨Á¢Ä¿Â¼µÄȨÏÞ
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES #Ô¶³ÌÓû§µÇ¼ij¸öÌØ¶¨Ä¿Â¼Ê±ÏÔʾµÄÐÅÏ¢
#
# Activate logging of uploads/downloads.
xferlog_enable=YES #¼¤»î¼Ç¼ÉÏ´«/ÏÂÔØ»î¶¯
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES #È·¶¨´«ÊäÁª½Ó¶Ë¿Ú´Ó20¿ªÊ¼
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log #Äã¿ÉÒÔËæÒâÖ¸¶¨log¼Ç¼ÎļþµÄλÖúÍÃû×Ö.ÏÂÃæµÄÊÇĬÈϵÄ
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600 ##Äã¿ÉÒÔÉ趨ĬÈϵĿÕÏг¬Ê±Ê±¼ä
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120 ##Äã¿ÉÒÔÉ趨ĬÈϵÄÊý¾ÝÁ¬½Ó³¬Ê±Ê±¼ä
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES #¿ÉÄܻὫһЩÀÏftp¿Í»§¶ËµÄÇëÇó¾ÜÖ®ÃÅÍâ
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# 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.
#Äã¿ÉÒÔÓÃÒ»¸öÁбíÏÞ¶¨ÄÄЩ±¾µØÓû§Ö»ÄÜÔÚ×Ô¼ºÄ¿Â¼Ï».Èç¹ûchroot_local_user=YES,ÄÇôÕâ¸öÁбíÀïÖ¸¶¨µÄÓû§ÊDz»ÊÜÏÞÖÆµÄ
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
#Ö¸¶¨ÔÚ×Ô¼ºÄ¿Â¼»î¶¯µÄÓû§
chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# thsence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
listen=YES #¶ÀÁ¢Ä£Ê½£¨¼àÌý£©
listen_port=21 #¼àÌý¶Ë¿Ú
guest_enable=YES #ÔÊÐíÀ´±öÓû§·ÃÎÊ
guest_username=virtual #À´±öÓû§ÉèΪvirtual
pam_service_name=ftp.vu # ÈÏÖ¤ÎļþÖ¸¶¨
user_config_dir=/etc/vsftpd_user_conf #Ö¸¶¨ÐéÄâÓû§µÄĿ¼É趨
########vsftp############
ÐéÄâÓû§£¬¸ß¼¶ÉèÖÃ
1£ºvi /etc/xinetd.d/vsftpd °Ñdisable=NO ¸Ä³ÉYES ²»ÔÚÐèÒªËûÁË£¡
2£ºvi /etc/vsftpd.conf ÔÚ½áβ¼ÓÉÏlisten=YES
3: service xinetd stop
3: /usr/local/sbin/vsftpd /etc/vsftpd.conf &
¶ÀÁ¢·þÎñÒѾÆô¶¯ÁË
½¨Á¢Èý¸öÓû§Áбíͨ¹ýÎļþ
cat << ! > login.txt
>download
>123456
>upload
>123456
>lxt
>12345
>!
´ËÎļþµÄ¸ñʽÊÇ£ºµ¥ÐÐΪÓû§Ãû£¬Å¼ÊýÐÐΪÃÜÂë
1£ºdb_load -T -t hash -f login.txt /etc/vsftpd_login.db (¿ÚÁîÉú³Édb_loadÊDz®¿ËÀûµÄÈí¼þ)
2£ºchmod 600 /etc/vsftpd_login.db
3: cd vsftpd-2.0.5/EXAMPLE;cp VIRYUAL_USERS/vsftpd.pam /etc/pam.d/ftp.vu (½øÈëÄãµÄ½â
°üµÄÔ´ÂëĿ¼£¬°ÑÐéÄâÓû§µÄÈÏÖ¤Îļþ¿½±´µ½/etc/pam.d/Ï£©
4: useradd -d /home/ftpsite virtual£»chmod 700 /home/ftpsite;su - virtual -c "echo
hello>/homt/ftpsite/test.file #½¨Á¢ÐéÄâÓû§ËùÒª·ÃÎʵÄftpĿ¼²¢ÉèÖýö virtualÓû§·ÃÎʵÄ
#ȨÏ޺ʹ´½¨Ò»¸ö¹©ÏÂÔØÊµÑéµÄÎļþ
5: vi /etc/vsftpd.confÔÚ´ËÎļþÖвåÈëÏÂÃæµÄÅäÖÃÓï¾ä
guest_enable=YES ÆôÓÃÐéÄâÓû§
guest_username=virtual ½«ÐéÄâÓû§Ó³ÉäΪ±¾µØvirtualÓû§
pam_service_name=ftp.vu Ö¸¶¨PAMÅäÖÃÎļþΪftp.vu£©
user_config_dir=/etc/vsftpd_user_conf Ö¸¶¨²»Í¬ÐéÄâÓû§ÅäÖÃÎļþµÄ´æ·Å·¾¶£©
6: mkdir /etc/vsftpd_user_conf
#¿ª·ÅdownloadÓû§µÄÏÂÔØÈ¨ÏÞ----Ö»ÄÜÏÂÔØ
7: echo "anon_world_readable_only=NO"> /etc/vsftpd_user_conf/download
#´´½¨uploadµÄÅäÖÃÎļþ
8£ºcp /etc/vsftpd_user_conf/download /etc/vsftpd_user_conf/upload
vi /etc/vsftpd_user_conf/upload
write_enable=YES #Ôö¼ÓдȨÏÞ
anon_upload_enable=YES #Ôö¼ÓÉÏ´«È¨ÏÞ
anon_mkdir_write_enable=YES #Ôö¼Ó´´½¨Ä¿Â¼µÄȨÏÞ
#´´½¨³¬¼¶Óû§µÄȨÏÞ
9£ºcp /etc/vsftpd_user_conf/upload /etc/vsftpd_user_conf/admin
anno_other_writer_enable=YES Ôö¼Ó¹ÜÀíÔ±Óû§µÄɾ³ý/ÖØÃüÃûµÄȨÏÞ
һЩÅäÖÃÎļþºÍÆô¶¯³ÌÐò¶¼ÔÚ±àÒëºóµÄÔ´´úÂëĿ¼À�±´µ½ÏàÓ¦µÄĿ¼¾Ã¿ÉÒÔÓÃ
Ð¶ÔØ vsftpdµÄ·½·¨£¨tar °²×°·½·¨£©
rm /usr/local/sbin/vsftpd
rm /usr/local/man/man5/vsftpd.conf.5
rm /usr/loval/man/man8/vsftpd.8
rm /etc/xinetd.d/vsftpd
rm /etc/vsftpd.conf
Ò»¸ö»ù±¾µÄvsftpdµÄ°²×°Åä»ú¾ÍÍê³ÉÁË£¬»¹ÓÐÒ»¸öFTP·þÎñÆ÷Èí¼þ pro ftp Ïà¶ÔÒª¼òµ¥Ò»µã£¬´óÌåÓ¦¸Ã²î²»¶à£¬ÓжÔftp°²×°ÅäÖÃÓÐʲôºÃµÄ¼û½âµÄÈË£¬¿ÉÒÔÁôÑÔ£¬Thank you¡£

