上传到Linux FTP服务器 /tmp 目录
关闭服务
service ftpd stop
service iptables stop
chconfig iptables off
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config;
setenforce 0
检查旧版ftpd 版本
ftpd -v
卸载旧版ftpd
yum remove -y ftpd
安装依赖包:
yum install -y libcap libcap-devel tcp_wrappers tcp_wrappers-devel
编译安装源码包
tar -xzvf ftpd-3.0.3.tar.gz
cd ftpd-3.0.3
vim builddefs.h
#ifndef VSF_BUILDDEFS_H
#define VSF_BUILDDEFS_H
#define VSF_BUILD_TCPWRAPPERS
#define VSF_BUILD_PAM
#undef VSF_BUILD_SSL
#endif /* VSF_BUILDDEFS_H */
sed -i 's/UTF8 ON/DISABLE UTF8 ON/g' opts.c
make && make install
mkdir /etc/ftpd/
cp ftpd.conf /etc/ftpd/
cp RedHat/ftpd.pam /etc/pam.d/ftp
sed -i 's/lib//lib64//g' /etc/pam.d/ftp
修改配置文件(去掉后面注释)
vi /etc/ftpd/ftpd.conf
anonymous_enable=No
local_enable=YES
write_enable=YES
dirmessage_enable=YES
max_clients=100
#listen_port=8080
pasv_min_port=30000
pasv_max_port=30100
local_root=/FTP
chroot_local_user=YES
allow_writeable_chroot=YES
启动并查看ftpd
/usr/local/sbin/ftpd &
netstat -tunlp | grep 21
/usr/local/sbin/ftpd -v
cp /usr/local/sbin/ftpd /usr/sbin/ftpd
制作启动脚本
vim /etc/xinetd.d/ftpd
disable = yes
vim /etc/init.d/ftpd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: ftpd
# Required-Start: $local_fs $network $named $remote_fs $syslog
# Required-Stop: $local_fs $network $named $remote_fs $syslog
# Short-Description: Very Secure Ftp Daemon
# Description: ftpd is a Very Secure FTP daemon. It was written completely from
# scratch
### END INIT INFO
# ftpd This shell script takes care of starting and stopping
# standalone ftpd.
#
# chkconfig: - 60 50
# description: ftpd is a ftp daemon, which is the program
# that answers incoming ftp service requests.
# processname: ftpd
# config: /etc/ftpd/ftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
RETVAL=0
prog="ftpd"
start() {
# Start daemons.
if [ -d /etc ] ; then
for i in `ls /etc/ftpd/ftpd.conf`; do
site=`basename $i .conf`
echo -n $"Starting $prog for $site: "
/usr/local/sbin/ftpd $i &
RETVAL=$?
[ $RETVAL -eq 0 ] && {
touch /var/lock/subsys/$prog
success $"$prog $site"
}
echo
done
else
RETVAL=1
fi
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
授权755
chmod 755 /etc/init.d/ftpd
chkconfig ftpd on
验证
service ftpd restart
ftpd -v
--禁止本地ftp用户访问操作系统
usermod -s /sbin/nologin ftpuser