惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

博客园 - 白虎

软件架构设计的六大原则 Linux 安装npm 下载ECharts Linux 安装WebStorm Linux配置开机自启动执行脚本 Linux挂载第二块硬盘 Linux 安装Nginx Linux个性终端Oh my zsh Linux 第一个脚本程序 Jigloo 下载 安装 GUI Linux应用开发入门(转) NET(C#)连接各类数据库-集锦 C# 编写最小化时隐藏为任务栏图标的Window appllication 管理型交换机IEEE 802.1Q VLAN设置应用实例 Windows Server 2012如何实现双网卡绑定 多网卡的7种bond模式原理 For Linux Eplan中电缆源和目标的确定规则 Eplan 2D安装版布局,部件、端子竖放 EPLAN Electric P8 2.0即将到来,着实令人期待-转caodaping 关于STM32 CAN回环可用,正常不可用情况分析
Linux 8开启FTP功能服务
白虎 · 2021-02-15 · via 博客园 - 白虎

不是很懂,简单写一下过程。本地账户测试的。

1、安装服务器

2、编辑配置文件

vim /etc/vsftpd/ftpusers #用户文件 我这些都没改
vim /etc/vsftpd/user_list #用户文件 我这些都没改
vim /etc/vsftpd/vsftpd.conf #配置文件 这个改了,请看以下
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
# with the listen_ipv6 directive.
listen=NO #注意这个不能开启,会有错误,启动不了。
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES

遇到的错误如下:

● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2021-02-15 13:19:43 CST; 19s ago
Process: 10312 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=2)
Main PID: 9813 (code=killed, signal=TERM)

2月 15 13:19:43 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
2月 15 13:19:43 localhost.localdomain systemd[1]: vsftpd.service: Control process exited, code=exited status=2
2月 15 13:19:43 localhost.localdomain vsftpd[10312]: 500 OOPS: run two copies of vsftpd for IPv4 and IPv6
2月 15 13:19:43 localhost.localdomain systemd[1]: vsftpd.service: Failed with result 'exit-code'.
2月 15 13:19:43 localhost.localdomain systemd[1]: Failed to start Vsftpd ftp daemon.


3、关闭防火墙

#开放两个端口:
firewall-cmd --zone=public --add-port=21/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent
#或者关闭防火墙
systemctl stop firewalld 
#针对于CenOS8 Redhat8
#优化防火墙设置
暂时开启FTP服务
firewall-cmd --add-service=ftp
永久开放FTP服务
firewall-cmd --add-service=ftp --permanent
永久关闭FTP服务
firewall-cmd --remove-service=ftp --permanent
重启防火墙使设置生效
systemctl restart firewalld

5、开启目录

setsebool -P tftp_home_dir on
sestatus -b | grep ftp

getsebool -a|grep ftp
setsebool -P allow_ftpd_full_access on
#setsebool -P tftp_home_dir on

4、启动服务

systemctl restart vsftpd.service
systemctl status vsftpd.service

#成功提示如下:

● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-02-15 13:24:08 CST; 3s ago
Process: 10465 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 10466 (vsftpd)
Tasks: 1 (limit: 22983)
Memory: 544.0K
CGroup: /system.slice/vsftpd.service
└─10466 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

5、本机测试

#安装客户端
yum install ftp
#测试服务
ftp xxx.xxx.xxx.xxx

 6、问题,

530 Login incorrect.

需检查用户shell是否正确,可用终端登录一下用户。

cat  /etc/passwd 和 cat /etc/shells 中是否有该shell存在。

500 OOPS: vsftpd: refusing to run with writable root inside chroot() Login f

vsftpd增强了安全,根目录下不能有写的权限,两种解决方式,

一种 chmod a-w 目录,

另一种在config中添加一条,allow_writeable_chroot=YES 屏蔽此安全。

关于两种用户设置:

  • chroot_local_user #是否将所有用户限制在主目录,YES为启用 NO禁用.(该项默认值是NO,即在安装vsftpd后不做配置的话,ftp用户是可以向上切换到要目录之外的)
  • chroot_list_enable #是否启动限制用户的名单 YES为启用  NO禁用(包括注释掉也为禁用)
  • chroot_list_file=/etc/vsftpd/chroot_list #是否限制在主目录下的用户名单,至于是限制名单还是排除名单,这取决于chroot_local_user的值,我们可以这样记忆: chroot_local_user总是一个全局性的设定,其为YES时,全部用户被锁定于主目录,其为NO时,全部用户不被锁定于主目录。那么我们势必需要在全局设定下能做出一些“微调”,即,我们总是需要一种“例外机制",所以当chroot_list_enable=YES时,表示我们“需要例外”。而”例外“的含义总是有一个上下文的,即,当”全部用户被锁定于主目录“时(即chroot_local_user=YES),"例外"就是:不被锁定的用户是哪些;当"全部用户不被锁定于主目录"时(即chroot_local_user=NO),"例外"“就是:要被锁定的用户是哪些。这样解释和记忆两者之间的关系就很清晰了!

# 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.
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 David.DU 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
allow_writeable_chroot=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=NO
listen_port=21
max_clients=100
max_per_ip=10
#
# 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=YES

pam_service_name=vsftpd
userlist_enable=NO
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list

pasv_enable=YES
#pasv_promiscuous=NO
pasv_min_port=30000
pasv_max_port=30999

#pasv_address=192.168.80.141
#pasv_addr_resolve=YES

View Code