1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# vsftpd-3.0.2.tar.gz
useradd  -s  /sbin/nolog  nobody
mkdir  /usr/share/empty/
mkdir  /var/ftp
useradd  -d  /var/ftp  ftp
chown  root:root  /var/ftp
chmod  og-w  /var/ftp
# 1)解压
tar  -zxvf vsftpd-3.0.2. tar .gz
# 2)编译安装
cd  vsftpd-3.0.2
make
make  install
cp  vsftpd.conf  /etc/
cp  vsftpd.conf.5  /usr/local/share/man/man5
cp  vsftpd.8  /usr/local/share/man/man8
===================================================
# 3)配置
/etc/vsftpd .conf
anonymous_enable=NO  #禁止匿名登录
local_enable=YES     #开启本地用户登录
write_enable=YES     #允许写入
local_umask=022      #上传后修改文件掩码
xferlog_enable=YES   #是否启用日志
xferlog_std_format=YES  #日志格式
xferlog_file=DIR     # 日志文件存放的目录
ftpd_banner=STRING   # 设置欢迎信息
anon_max_rate=100000  #设置匿名用户最大传输速录为100KB/s
local_enable=YES
write_enable=YES
local_unmask=022
local_max_rate=200000  #用户最大传输速录为200KB/s
!注意 如果一定要启用SELinux 下允许用户上传文件到目录则需要执行
setsebool -P ftp_home_dir 1
setsebool -P allow_ftpd_full_access 1
# 限制指定的用户不能访问,而其他用户可以访问
userlist_enable=YES  #是否启用访问控制列表功能
userlist_deny=YES    # 这里写什么值 就是下面列出用户是否可以登录
userlist_file= /etc/vsftpd .user_list
# 限制指定的用户可以访问,而其他用户不可以访问 *推荐
userlist_enable=YES
userlist_deny=NO
userlist_file= /etc/vsftpd .user_list
# 设置 chroot
# 把宿主目录当做根目录进行访问 无法访问别人的目录
# 设置所有用户执行chroot
chroot_local_user=YES
# 设置指定的用户不执行chroot
chroot_local_user=YES
chroot_local_enable=YES
chroot_list_file= /etc/vsftpd/chroot_list
# 其他设置选项
idle_session_timeout=600  #用户空闲10分钟后挂断 单位为秒
max_clients=50  #服务器的总的并发连接数为50
max_per_ip=3  #每个客户机的最大连接数为3
listen_port=10011  #指定非标准端口
============================================================
基本命令
ls
cd
bin - 二进制传输
lcd - 切换下载目录(本地)
get - 下载单个文件
mget - 下载多个文件
put - 上传单个文件
mput - 上传多个文件
prompt - 关闭交互模式
bye - 退出
open  IP - 连接主机
user USERNAME PASSWORD - 切换用户
==============================================================
shell
open  IP
user  ftp
bin
prompt
lcd  /ftp .bak
mget *
bye
*****
ftp  -n < auto.sh >  /dev/null
-n 关闭交互模式
就能把文件下载下来了
===============================================================
*************************************************************************
vim builddefs.h
============ builddefs.h ================
#undef VSF_BUILD_TCPWRAPPERS
#define VSF_BUILD_PAM
#undef VSF_BUILD_SSL
************** change ********************
#define VSF_BUILD_TCPWRAPPERS
#define VSF_BUILD_PAM
#define VSF_BUILD_SSL
==========================================
=========== 依赖关系 ======================
# tcp_wrappers
wget  ftp : //ftp .porcupine.org /pub/security/tcp_wrappers_7 .6. tar .gz
tar  -zxvf tcp_wrappers_7.6. tar .gz
cd  tcp_wrappers_7.6
# mkdir REAL_DAEMON_DIR
     # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
     # cp tcpd /usr/etc/in.fingerd
============================================