Linux搭建ftp服务 vsftpd

发布于 2022-04-14  21 次阅读


安装vsftpd
yum install vsftpd

创建用户并且设置密码
useradd -d /home/ftp -s /sbin/nologin ftpuser
passwd ftpuser

权限加一下
chown -R ftpuser:ftpuser ftpuser
chmod -R 755 ftpuser

导入配置文件

/etc/vsftpd/vsftpd.conf

listen=YES
# 禁用匿名模式
anonymous_enable=NO
#
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
#具有写权限
write_enable=YES
#
#本地用户创建文件或目录的掩码
local_umask=022
# Activate directory messages - messages given to remote users when they
dirmessage_enable=YES
#
#当设定为YES时,使用者上传与下载日志都会被纪录起来。记录日志与下一个xferlog_file设定选项有关
#xferlog_enable=YES
#xferlog_std_format=YESxferlog_file=/var/log/xferlog
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES

#chown_uploads=YES
#chown_username=whoever
#idle_session_timeout=600
#
#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
#
# async_abor_enable=YES
#
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=NO
ascii_download_enable=NO
#
# 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
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)-该文件记得要有相应用户读写权限
chroot_list_file=/etc/vsftpd/chroot_list
#chroot_list_file=/home/ftp/
#ls_recurse_enable=YES
#
#listen=NO
#
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=NO
tcp_wrappers=YES
#allow_writeable_chroot=YES
listen_port=21

#FTP访问目录
local_root=/home/ftp/
#被动模
pasv_enable=YES
#被动模式对外提供端口
pasv_min_port=65400
pasv_max_port=65410

重启服务

systemctl restart vsftpd
service vsftpd start


因为喜欢所以折腾。。。