温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

selinux导致ftp上传失败如何解决

发布时间:2021-07-22 14:43:17 来源:亿速云 阅读:143 作者:chen 栏目:系统运维

这篇文章主要介绍“selinux导致ftp上传失败如何解决”,在日常操作中,相信很多人在selinux导致ftp上传失败如何解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”selinux导致ftp上传失败如何解决”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!



1、手动的执行ftp上传动作,报如下错误:553 Could not create file.

sshuser@station90.example.com:~/xunjian/0108> ftp 192.168.1.123
Connected to 192.168.1.123.
220 (vsFTPd 2.0.5)
Name (192.168.1.123:oracle): oracle
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>binary
200 Switching to Binary mode.
ftp> put xunjian_0108.zip
local: xunjian_0108.zip remote: xunjian_0108.zip
229 Entering Extended Passive Mode (|||10717|)
553 Could not create file.

2、代理PC的oracle家目录,肯定是有读写权限的,因为是代理PC重启导致的,突然想到selinux若开启的话,是不允许用户的家目录进行ftp的,需要将ftp_home_dir这个sebool打开,如下所示:

[root@squid ~]# getenforce
Enforcing
[root@squid ~]# getsebool -a | grep ftp_home_dir
ftp_home_dir --> off
[root@squid ~]# setsebool ftp_home_dir on

3、这时候去上传,就可以成功了,如下所示

sshuser@station90.example.com:~/xunjian/0108> ftp 192.168.1.123
Connected to 192.168.1.123.
220 (vsFTPd 2.0.5)
Name (192.168.1.123:oracle): oracle
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bi
200 Switching to Binary mode.
ftp> put xunjian_0108.zip
local: xunjian_0108.zip remote: xunjian_0108.zip
229 Entering Extended Passive Mode (|||19974|)
150 Ok to send data.
100% |***********************************************************************| 577 KB 2.31 MB/s 00:00 ETA
226 File receive OK.
591290 bytes sent in 00:00 (2.18 MB/s)

4、另外一种方式,就是将selinux设置为Permissive

[root@squid ~]# getenforce
Enforcing
[root@squid ~]# setenforce 0
[root@squid ~]# getenforce
Permissive

5、同时在/etc/rc.local中添加这么一行,那么下次系统重启后,就不会发生这样的情况了

[root@squid ~]# which setenforce
/usr/sbin/setenforce
[root@squid ~]# cat /etc/rc.local | tail -n 1
/usr/sbin/setenforce 0

到此,关于“selinux导致ftp上传失败如何解决”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI