安装vsftpd
[root@lnmp ]# yum install vsftpd -y
配置文件添加 anon_root=/opt,指匿名用户的FTP根目录
[root@lnmp ]# vi /etc/vsftpd/vsftpd.conf
[root@lnmp ]# cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
anon_root=/opt
#
# 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.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
关闭防火墙,并设置开机不自启
[root@lnmp ~]# systemctl stop firewalld
[root@lnmp ~]# systemctl disable firewalld
查看端口
[root@lnmp ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7066/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6523/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1117/sshd
tcp6 0 0 :::21 :::* LISTEN 32334/vsftpd
tcp6 0 0 :::22 :::* LISTEN 1117/sshd
用文件夹查看
设置匿名用户可上传文件
未加权限前
建立用户并且登录
需要给它的配置文件加权限
``[root@lnmp ~]# useradd user001
[root@lnmp ~]# passwd user001
Changing password for user user001.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@lnmp ~]#
[root@lnmp ~]# vi /etc/vsftpd/vsftpd.conf
#Example config file /etc/vsftpd/vsftpd.conf
#anon_root=/opt
#
#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.
#When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
#Uncomment this to enable any form of FTP write command.
write_enable=YES
#
#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
#
#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.
#When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
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
#
#Activate directory messages - messages given to remote users when they
#go into a certain directory.
dirmessage_enable=YES
#
#Activate logging of uploads/downloads.
xferlog_enable=YES
#
#Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
#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/xferlog
#
#If you want, you can have your log file in standard ftpd xferlog format.
#Note that the default log file location is /var/log/xferlog in this case.
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
#
#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. The vsftpd.conf(5) man page explains
#the behaviour when these options are disabled.
#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.
#deny_email_enable=YES
#When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#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
#
#Activate directory messages - messages given to remote users when they
#go into a certain directory.
dirmessage_enable=YES
#
#Activate logging of uploads/downloads.
xferlog_enable=YES
#
#Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
#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/xferlog
#
#If you want, you can have your log file in standard ftpd xferlog format.
#Note that the default log file location is /var/log/xferlog in this case.
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
#
"/etc/vsftpd/vsftpd.conf" 129L, 5129C written
[root@lnmp ~]#
[root@lnmp ~]# vi /etc/vsftpd/chroot_list
user001
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vsftpd/chroot_list" [New] 1L, 8C written`