Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

vsftpd 無法上傳下載:500 OOPS 錯誤的完整解法

在 64 位元 RHEL6 上,vsftpd 登入時出現 500 OOPS: cannot change directory:/home/*******,甚至伴隨 500 OOPS: child died,十次有九次不是權限問題,而是 SELinux 把家目錄擋住了。

一、先排除權限

確認目錄存在、擁有者正確、權限可讀可寫,這一步先做完再往下。

二、調整 SELinux 布林值

setsebool -P ftpd_disable_trans 1
service vsftpd restart

或更精準地放行家目錄:

/usr/sbin/setsebool -P ftp_home_dir 1

-P 代表永久生效,重開機後仍保留。

三、若出現 libsemanage 錯誤

執行 setsebool -P ftpd_disable_trans 1 時看到:

libsemanage.dbase_llist_set: record not found in the database
Could not change boolean ftpd_disable_trans

代表這個布林值在你的 policy 中不存在,改用 ftp_home_dir 即可:

/usr/sbin/setsebool -P ftp_home_dir 1

四、完全放行模式

若上面兩招都無效,把相關布林值一次打開:

setsebool allow_ftpd_full_access 1
setsebool allow_ftpd_use_cifs 1
setsebool allow_ftpd_use_nfs 1
setsebool -P ftp_home_dir 1
setsebool httpd_enable_ftp_server 1
setsebool tftp_anon_write 1
service vsftpd restart

用以下指令檢視目前狀態:

getsebool -a | grep ftp

allow_ftpd_anon_write --> off
allow_ftpd_full_access --> on
allow_ftpd_use_cifs --> on
allow_ftpd_use_nfs --> on
ftp_home_dir --> on
ftpd_connect_db --> off
httpd_enable_ftp_server --> on
tftp_anon_write --> on

重啟 vsftpd 後即可正常上傳下載。提醒一句:這些設定會實質放寬 FTP 的存取範圍,正式環境請只開啟真正需要的那一項,而非全部打開。

Copyright © Linux教程網 All Rights Reserved