ftp服务端配置
yum -y install vsftpd --下载ftp服务器
编辑配置文件
vim /etc/vsftpd/vsftpd.conf
配置文件内容:
# Example config file /etc/vsftpd/vsftpd.conf
#
# 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=NO
#
# 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
# 本地用户的文件umask码
#
# 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
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=NO
pam_service_name=vsftpd
#设置PAM使用的名称
userlist_enable=YES
tcp_wrappers=YES
ascii_upload_enable=NO
#是否启用ASCII模式上传数据
ascii_download_enable=NO
#是否启用ASCII模式下载数据
chroot_local_user=YES
#是否禁止本地用户切换到家目录上级目录
chroot_list_enable=YES
#是否启用例外名单,默认NO
chroot_list_file=/etc/vsftpd/chroot_list
#chroot_list_file文件中的用户可以切换到其他目录
#chroot_local_user=NO,chroot_list_enable=YES
#chroot_list_file文件中的用户将锁定在家目录下
#chroot_local_user=YES,chroot_list_enable=NO
#所有本地用户都锁定在家目录下
#chroot_local_user=NO,chroot_list_enable=NO
#所有本地用户都可以切换到其他目录
allow_writeable_chroot=YES
#所有的用户都将拥有chroot权限。
#listen_port=9011
#设置ftp服务工作的端口,默认21
pasv_enable=YES
#YES为被动模式工作,NO则是主动模式,默认YES
pasv_min_port=65400
#PASV模式下,最小传输数据端口号,0为任意无限制
pasv_max_port=65410
#PASV模式下,最大传输数据端口号,0为任意无限制
local_root=/home/aaa
#本地用户登陆后改变的目录,默认是各自家目录
pasv_promiscuous=YES
#代表关闭PASV模式的安全检查
pasv_address=***.**.***.***
#本机ip地址
#local_max_rate=0(unlimited)
#本地用户使用的最大传输速度,单位为B/s
#listen=YES
#设 置vsftpd服务器是否以standalone模式运行,有很多与服务器运行相关的配置命令,需要在此模式下才有效
#若设置为NO,则vsftpd以super daemon运行,要受到xinetd 服务的管控,功能上会受到限制
#max_clients=0(unlimited)
#设置客户端最大连接数,standalone模式下有效
#max_per_ip=0(unlimited)
#同一IP客户端最大连接数,standalone模式下有效
ftp服务器配置详情地址
https://www.cnblogs.com/houyongchong/p/10283995.html
配置说明
当userlist_enable=YES时,userlist_deny=YES时:user_list是一个黑名单,即:所有出现在名单中的用户都会被拒绝登入;
当userlist_enable=YES时,userlist_deny=NO时:user_list是一个白名单,即:只有出现在名单中的用户才会被准许登入(user_list之外的用户都被拒绝登入);另外需要特别提醒的是:使用白名单后,匿名用户将无法登入!除非显式在user_list中加入一行:anonymous
编辑配置文件chroot_list,里面的用户为限制只访问设定的目录用户
复制一个user_list文件,改名为,chroot_list
编辑chroot_list,添加用户
新建一个ftp用户
useradd aaa --建一个aaa用户
passwd aaa --设置aaa的密码
更改ftp用户的权限
vim /etc/shells
添加一行
/sbin/nologin
vim /etc/passwd
改为/sbin/nologin --限制ftp用户不能登录shell,只能通过ftp访问能访问的目录
aaa:x:1001:1001::/home/aaa:/sbin/nologin
ftp服务 启停命令
systemctl start vsftpd --启动
systemctl restart vsftpd --重启
systemctl stop vsftpd --停止
ftp客户端操作命令
ftp> lcd /home/cmaq/ceshi --指定下载到的路径
Local directory now /home/cmaq/ceshi
ftp> prompt off --批量下载开启不用每条确认
Interactive mode off.
ftp> mget *.bin --批量下载