1
2
3
4
5
6
7
8
9
10
|
/etc/logrotate.d/vsftpd
//配置日志回滚的文件
/etc/pam.d/vsftpd
//定义vsftpd是如何认证用户的,默认情况vsftpd支持使用匿名用户和本地用户
/etc/rc.d/init.d/vsftpd
//服务启动脚本
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
//服务的主配置文件
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
//服务器端程序
/
var
/ftp
//ftp的默认家目录
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@station92~]# ftp172.
16.2
.
1
//连接测试
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd
2.2
.
2
)
//220是协议响应码,表示正常响应
Name(
172.16
.
2.1
:root): ftp
//表示匿名访问
331Please specify the password.
Password:
//匿名用户登录密码为空
230Login successful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/"
//匿名用户默认被锁定在“/“目录下,而本地用户没有被锁定,因此看以看所有的文件
[root@stu2 ~]# finger ftp
Login:ftp Name: FTP User
Directory:/
var
/ftp Shell: /sbin/nologin
Neverlogged
in
.
Nomail.
NoPlan.
其中Directory: /
var
/ftp表示用户家目录路径信息
|
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
|
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd
2.2
.
2
)
Name(
172.16
.
2.1
:root): gentoo
331Please specify the password.
Password:
230Login successful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp>pwd
257
"/users/gentoo"
ftp>ls
227Entering Passive Mode (
172
,
16
,
2
,
1
,
236
,
228
).
150Here comes the directory listing.
-rw-rw-r--
1
500
500
73175088
Jul
10
03
:18linux-
3.10
.tar.xz
226Directory send OK.
服务器端查看本地用户信息
[root@stu2~]# finger gentoo
Login:gentoo Name:
Directory:/users/gentoo Shell: /bin/bash
Lastlogin Sat Aug
17
09
:
54
(CST) on pts/
1
from
172.16
.
254.54
Nomail.
NoPlan.
Root用户默认没有访问权限
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): root
530
Permissiondenied.
Loginfailed.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@stu2~]# grep -v
"^#"
/etc/vsftpd/vsftpd.conf | grep -v
"^$"
anonymous_enable=YES
//允许匿名用户访问,若禁止使用NO
local_enable=YES
//允许本地用户访问,若禁止则使用NO
write_enable=YES
//表示是否允许本地用户有上传权限的,YES表示可以,NO表示禁止,也取决于客户端连接时使用的客户端工具
local_umask=
022
//设置本地用户上传建立文件时的权限掩码
dirmessage_enable=YES
//用户切换进入目录时显示.message(如果存在)文件的内容
xferlog_enable=YES
//是否开启传输日志的
connect_from_port_20=YES
//连接控制端口为20
xferlog_std_format=YES
//启动标准xferlog的日志格式,若禁用此项,将使用vsftpd自己的日志格式
listen=YES
//是否以独立运行的方式监听服务
pam_service_name=vsftpd
//设root
userlist_enable=YES
//表明启动本地用户
tcp_wrappers=YES
//是否开启tcp_wrappers主机访问控制
除此之外还有注释掉的,有些可以启动的具体为:
#anon_upload_enable=YES#是否匿名用户上传文件
#anon_mkdir_write_enable=YES#匿名用户具有创建目录的权限
可以加一条
Anon_other_write_enable=YES#其他权限,可是设置文件的属主属组,删除等操作
#xferlog_file=/
var
/log/xferlog#记录传输日志内容的
#idle_session_timeout=
600
#命令连接的超时时间
#data_connection_timeout=
120
#数据连接的超时时间
#chroot_local_user=YES
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
|
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
|
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): gentoo
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/"
//本地用户被锁定在家目录下
ftp> ls
227Entering Passive Mode (
172
,
16
,
2
,
1
,
195
,
144
).
150
Herecomes the directory listing.
-rw-r--r--
1
500
500
921
Aug
19
00
:16fstab
-rw-rw-r--
1
500
500
73175088
Jul
10
03
:18linux-
3.10
.tar.xz
226Directory send OK.
ftp> cd/
250Directory successfully changed.
ftp> ls
227Entering Passive Mode (
172
,
16
,
2
,
1
,
231
,
75
).
150
Herecomes the directory listing.
-rw-r--r--
1
500
500
921
Aug
19
00
:16fstab
-rw-rw-r--
1
500
500
73175088
Jul
10
03
:18linux-
3.10
.tar.xz
226Directory send OK.
|
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
|
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): centos
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/"
//锁定用户的家目录
ftp> bye
221Goodbye.
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): gentoo
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/"
//锁定用户的家目录
ftp> bye
221Goodbye.
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): hailian
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/home/hailian"
//没有锁定
|
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
|
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): gentoo
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/users/gentoo"
ftp> bye
221Goodbye.
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): centos
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/users/centos"
ftp> bye
221Goodbye.
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): hailian
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> pwd
257
"/"
|
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
|
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): ftp
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> put/etc/fstab
local:/etc/fstab remote: /etc/fstab
227Entering Passive Mode (
172
,
16
,
2
,
1
,
50
,
195
).
550Permission denied.
//匿名用户不允许有上传权限
本地用户:
[root@station92~]# ftp
172.16
.
2.1
Connectedto
172.16
.
2.1
(
172.16
.
2.1
).
220
(vsFTPd2.
2.2
)
Name(
172.16
.
2.1
:root): gentoo
331
Pleasespecify the password.
Password:
230
Loginsuccessful.
Remotesystem type
is
UNIX.
Usingbinary mode to transfer files.
ftp> put/etc/fstab
local:/etc/fstab remote: /etc/fstab
227Entering Passive Mode (
172
,
16
,
2
,
1
,
90
,
137
).
//ftp工作在被动模式下
553
Couldnot create file.
//表明上传功能没问题,但无法创建文件
ftp> pwd
257
"/users/gentoo"
|
1
2
3
4
5
6
7
8
9
|
[root@station92~]# lftp gentoo@
172.16
.
2.1
Password:
lftpgentoo@
172.16
.
2.1
:~> ls
-rw-rw-r--
1
500
500
73175088
Jul
10
03
:18linux-
3.10
.tar.xz
lftpgentoo@
172.16
.
2.1
:~> put /etc/fstab
921
bytestransferred
//实现了上传功能
lftpgentoo@
172.16
.
2.1
:~> ls
-rw-r--r--
1
500
500
921
Aug
19
00
:16fstab
-rw-rw-r--
1
500
500
73175088
Jul
10
03
:18linux-
3.10
.tar.xz
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@stu2~]# cd /
var
/ftp/
[root@stu2ftp]# ll
total
4
drwxr-xr-x2 root root
4096
Aug
18
01
:
58
pub
[root@stu2ftp]# mkdir upload
[root@stu2ftp]# setfacl -m u:ftp:rwx upload/
[root@stu2ftp]# getfacl upload/
# file: upload/
# owner:root
# group:root
user::rwx
user:ftp:rwx
group::r-x
mask::rwx
other::r-x
|
1
2
3
4
5
6
7
8
|
[root@station92~]# lftp
172.16
.
2.1
lftp172.
16.2
.
1
:~> ls
drwxr-xr-x
2
0
0
4096
Aug
17
17
:
58
pub
drwxrwxr-x
2
0
0
4096
Aug
19
02
:54upload
lftp172.
16.2
.
1
:/> cd upload/
lftp172.
16.2
.
1
:/upload> ls
lftp172.
16.2
.
1
:/upload> put /etc/fstab
921
bytestransferred
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@station92~]# lftp
172.16
.
2.1
lftp172.
16.2
.
1
:~> ls
drwxr-xr-x
2
0
0
4096
Aug
17
17
:
58
pub
drwxrwxr-x
2
0
0
4096
Aug
19
08
:16upload
lftp172.
16.2
.
1
:/> cd upload/p
cd: Accessfailed:
550
Failed to change directory. (/upload/p)
lftp172.
16.2
.
1
:/> cd upload/
lftp172.
16.2
.
1
:/upload> ls
-rw-------
1
14
50
921
Aug
19
03
:46fstab
-rw-------
1
14
50
103
Aug
19
08
:16issue
lftp172.
16.2
.
1
:/upload> mkdir test
mkdir ok,`test' created
lftp172.
16.2
.
1
:/upload> ls
-rw-------
1
14
50
921
Aug
19
03
:46fstab
-rw-------
1
14
50
103
Aug
19
08
:16issue
drwx------
2
14
50
4096
Aug
19
08
:21test
|
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
|
You areabout to be asked to enter information that will be incorporated
into yourcertificate request.
What youare about to enter
is
what
is
called a Distinguished Name or a DN.
There arequite a few fields but you can leave some blank
For somefields there will be a
default
value,
If youenter
'.'
, the field will be left blank.
-----
CountryName (
2
letter code) [XX]:CN
State orProvince Name (full name) []:henan
LocalityName (eg, city) [Default City]:zhengzhou
OrganizationName (eg, company) [Default Company Ltd]:ftp.magedu.com
OrganizationalUnit Name (eg, section) []:^C
[root@stu2ssl]# openssl req -
new
-key vsftpd.key -out vsftpd.csr
You areabout to be asked to enter information that will be incorporated
into yourcertificate request.
What youare about to enter
is
what
is
called a Distinguished Name or a DN.
There arequite a few fields but you can leave some blank
For somefields there will be a
default
value,
If youenter
'.'
, the field will be left blank.
-----
CountryName (
2
letter code) [XX]:CN
State orProvince Name (full name) []:henan
LocalityName (eg, city) [Default City]:zhengzhou
OrganizationName (eg, company) [Default Company Ltd]:magedu
OrganizationalUnit Name (eg, section) []:tech
Common Name(eg, your name or your server's hostname) []:ftp.magedu.com
EmailAddress []:caadmin@magedu.com
Pleaseenter the following
'extra'
attributes
to be sentwith your certificate request
A challengepassword []:
An optionalcompany name []:
[root@stu2ssl]# ls
vsftpd.csr vsftpd.key
|