一、安装
1.下载最新的稳定版vsftpd-3.0.0.tar.gz
2.卸载原有的rpm的vsftpd
rpm -e vsftpd
3.tar-zxvf vsftpd-3.0.0.tar.gz -C /usr/local/src
4.cd/usr/local/src/vsftpd-3.0.0/
5.make
6.useradd nobody
7.mkdir/usr/share/empty
8.mkdir /var/ftp
9.useradd -d/var/ftp ftp
10.chownroot.root /var/ftp
11.chmod og-w/var/ftp
12make install
13/usr/local/sbin/vsftpd & --启动
14.netstat–tulpn |grep vsftpd --查看
匿名登录:anonymous
用户登录:
1.修改配置文件:vim/etc/vsftpd.conf
local_enable=YES --去掉注释
2.cp RedHat/vsftpd.pam/etc/pam.d/ftp --复制并改名解压缩文件vsftpd3.0.0 下的 RedHat/vsftpd.pam 到 /etc/pam.d/ftp
3.修改完后关闭vsftpd 服务: pkill -9 vsftpd
4.重新启动vsftpd 服务/usr/local/sbin/vsftpd &
16.增加 vsftpd的启动脚本并加入chkconfig 管理,设置开机启动
17.vim /etc/init.d/vsftpd
18.chmod a+x /etc/init.d/vsftpd
19.chkconfig –add vsftpd
20.chkconfig –list vsftpd
21.servicevsftpd start | stop |restart |status –分
启动脚本如下: [root@ns init.d]# cat vsftpd #!/bin/bash #chkconfig: 2345 88 66 #description: vsftpd server. prog=/usr/local/sbin/vsftpd lockfile=/var/lock/subsys/vsftpd namearg=vsftpd . /etc/init.d/functions start () { if [ -e $lockfile ] ;then echo "the program $namearg is running." else echo -n "Starting $namearg ..." sleep 2 $prog & [ "$?" -eq 0 ] && touch $lockfile && echo -e "\t\t\t[\033[32m 0k \033[0m]" || echo -e "\t\t\t[\033[31m fail \033[0m]" fi } stop () { if [ -e $lockfile ] ;then echo -n "Stopping $namearg ..." sleep 2 killproc $namearg &>/dev/null && rm -rf $lockfile && echo -e "\t\t\t[\033[32m 0k \033[0m]" || echo -e "\t\t\t[\033[31m fail \033[0m]" else echo "the program $namearg is stoped." fi } status () { if [ -e $lockfile ] ;then echo "the program $namearg is running." else echo "the program $namearg is stoped. " fi } case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo "Usage: $namearg [start | stop | restart | status ]" ;; esac
参照 ftp 目录下的INSTALL cat INSTALL
hisfile details how to build and install / run vsftpd from the vsftpd
distribution.tar.gz file.
Step1) Build vsftpd.
Switchto the directory created when you unpacked the vsftpd .tar.gz file.
e.g.:
cdvsftpd-1.1.2
edit"builddefs.h" to handle compile-time settings (tcp_wrappers build,
etc).
Justtype "make" (and mail me to fix it if it doesn't build ;-).
Thisshould produce you a vsftpd binary. You can test for this, e.g.:
[chris@localhostvsftpd]$ ls -l vsftpd
-rwxrwxr-x 1 chris chris 61748 Sep 27 00:26vsftpd
Step2) Satisfy vsftpd pre-requisites
2a)vsftpd needs the user "nobody" in the default configuration. Add this
userin case it does not already exist. e.g.:
[root@localhostroot]# useradd nobody
useradd:user nobody exists
2b)vsftpd needs the (empty) directory /usr/share/empty in the default
configuration.Add this directory in case it does not already exist. e.g.:
[root@localhostroot]# mkdir /usr/share/empty/
mkdir:cannot create directory `/usr/share/empty': File exists
2c)For anonymous FTP, you will need the user "ftp" to exist, and have a
validhome directory (which is NOT owned or writable by the user "ftp").
Thefollowing commands could be used to set up the user "ftp" if you donot
haveone:
[root@localhostroot]# mkdir /var/ftp/
[root@localhostroot]# useradd -d /var/ftp ftp
(thenext two are useful to run even if the user "ftp" already exists).
[root@localhostroot]# chown root.root /var/ftp
[root@localhostroot]# chmod og-w /var/ftp
Step3) Install vsftpd config file, executable, man page, etc.
Running"make install" will try to copy the binary, man pages, etc. to
somewheresensible.
Oryou might want to copy these things by hand, e.g.:
cpvsftpd /usr/local/sbin/vsftpd
cpvsftpd.conf.5 /usr/local/man/man5
cpvsftpd.8 /usr/local/man/man8
"makeinstall" doesn't copy the sample config file. It is recommended you
dothis:
cpvsftpd.conf /etc
Step4) Smoke test (without an inetd).
vsftpdcan run standalone or via an inetd (such as inetd or xinetd). You will
typicallyget more control running vsftpd from an inetd. But first we will run
itwithout, so we can check things are going well so far.
Edit/etc/vsftpd.conf, and add this line at the bottom:
listen=YES
Thistells vsftpd it will NOT be running from inetd.
Right,now let's try and run it!
Login as root.
Makesure you are not running other FTP servers (or vsftpd will not be able
touse the FTP port, 21).
Runthe binary from wherever you put it, e.g.:
[root@localhostroot]# /usr/local/sbin/vsftpd &
[1]2104
Ifall is well, you can now connect! e.g.: