ftp问题--500 OOPS: failed to open ftp log file

本文介绍了解决本地FTP连接出现特定错误的方法。通过设置SElinux策略并重启VSFTP服务,可以有效解决连接问题。

今天pin ftp时,ftp localhost,出现了上述错误

解决方法:
在终端输入命令:
setsebool ftpd_disable_trans 1
service vsftpd restart
回车就可以了。

 

[root@localhost ~]# # 完整配置流程 [root@localhost ~]# sudo mkdir -p /var/ftp/upload [root@localhost ~]# sudo chmod 775 /var/ftp/upload [root@localhost ~]# sudo semanage fcontext -a -t public_content_rw_t "/var/ftp/upload(/.*)?" [root@localhost ~]# sudo restorecon -Rv /var/ftp restorecon reset /var/ftp/upload context unconfined_u:object_r:public_content_t:s0->unconfined_u:object_r:public_content_rw_t:s0 [root@localhost ~]# sudo setsebool -P allow_ftpd_full_access=1 [root@localhost ~]# sudo systemctl restart vsftpd Failed to restart vsftpd.service: Unit not found. [root@localhost ~]# ^C [root@localhost ~]# # 检查目录上下文 [root@localhost ~]# ls -Zd /var/ftp # 应显示 public_content_rw_t drwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 /var/ftp [root@localhost ~]# [root@localhost ~]# # 检查布尔值状态 [root@localhost ~]# getsebool -a | grep ftp ftpd_anon_write --> off ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> on ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off tftp_anon_write --> off tftp_home_dir --> off [root@localhost ~]# # 模拟文件上传测试 [root@localhost ~]# echo "test" | sudo tee /var/ftp/incoming/testfile.txt tee: /var/ftp/incoming/testfile.txt: 没有那个文件或目录 test [root@localhost ~]# curl -T localfile.txt ftp://localhost/incoming/ curl: Can't open 'localfile.txt'! curl: try 'curl --help' or 'curl --manual' for more information [root@localhost ~]# # 检查服务是否安装 [root@localhost ~]# rpm -q vsftpd 未安装软件包 vsftpd [root@localhost ~]# [root@localhost ~]# # 检查服务单元是否存在 [root@localhost ~]# systemctl list-unit-files | grep vsftpd [root@localhost ~]# sudo yum install vsftpd -y 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 正在解决依赖关系 --> 正在检查事务 ---> 软件包 vsftpd.x86_64.0.3.0.2-29.el7_9 将被 安装 --> 解决依赖关系完成 依赖关系解决 ======================================================================================================================== Package 架构 版本 源 大小 ======================================================================================================================== 正在安装: vsftpd x86_64 3.0.2-29.el7_9 updates 173 k 事务概要 ======================================================================================================================== 安装 1 软件包 总下载量:173 k 安装大小:353 k Downloading packages: vsftpd-3.0.2-29.el7_9.x86_64.rpm | 173 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : vsftpd-3.0.2-29.el7_9.x86_64 1/1 warning: /etc/vsftpd/vsftpd.conf created as /etc/vsftpd/vsftpd.conf.rpmnew 验证中 : vsftpd-3.0.2-29.el7_9.x86_64 1/1 已安装: vsftpd.x86_64 0:3.0.2-29.el7_9 完毕! [root@localhost ~]# sudo vi /etc/vsftpd/vsftpd.conf [root@localhost ~]# # 设置FTP目录上下文 (以/var/ftp为例) [root@localhost ~]# sudo semanage fcontext -a -t public_content_rw_t "/var/ftp(/.*)?" libsemanage.dbase_llist_query: could not query record value [root@localhost ~]# sudo restorecon -Rv /var/ftp restorecon reset /var/ftp context system_u:object_r:public_content_t:s0->system_u:object_r:public_content_rw_t:s0 restorecon reset /var/ftp/pub context system_u:object_r:public_content_t:s0->system_u:object_r:public_content_rw_t:s0 [root@localhost ~]# [root@localhost ~]# # 启用关键布尔值 [root@localhost ~]# sudo setsebool -P allow_ftpd_full_access=1 [root@localhost ~]# sudo setsebool -P ftp_home_dir=1 Boolean ftp_home_dir is not defined [root@localhost ~]# # 重载服务配置 [root@localhost ~]# sudo systemctl daemon-reload [root@localhost ~]# [root@localhost ~]# # 启动服务 [root@localhost ~]# sudo systemctl start vsftpd Job for vsftpd.service failed because the control process exited with error code. See "systemctl status vsftpd.service" and "journalctl -xe" for details. [root@localhost ~]# [root@localhost ~]# # 检查服务状态 [root@localhost ~]# sudo systemctl status vsftpdvsftpd.service - Vsftpd ftp daemon Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 六 2025-10-18 09:28:55 CST; 107ms ago Process: 5291 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=2) 10月 18 09:28:55 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon... 10月 18 09:28:55 localhost.localdomain vsftpd[5291]: 500 OOPS: bad bool value in config file for: anon_upload_enable 10月 18 09:28:55 localhost.localdomain systemd[1]: vsftpd.service: control process exited, code=exited status=2 10月 18 09:28:55 localhost.localdomain systemd[1]: Failed to start Vsftpd ftp daemon. 10月 18 09:28:55 localhost.localdomain systemd[1]: Unit vsftpd.service entered failed state. 10月 18 09:28:55 localhost.localdomain systemd[1]: vsftpd.service failed. [root@localhost ~]# # 测试本地用户上传 [root@localhost ~]# echo "test" > testfile.txt [root@localhost ~]# ftp -n localhost <<EOF > user <您的用户名> <密码> > put testfile.txt > quit > EOF bash: ftp: 未找到命令... [root@localhost ~]# [root@localhost ~]# # 检查SELinux日志 [root@localhost ~]# sudo ausearch -m avc -c vsftpd | audit2why <no matches> Nothing to do
最新发布
10-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值