Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

CentOS pure-ftpd 530 Login authentication failed 完整排查手冊

編輯:關於 Linux

錯誤現象

lftp feifei@192.168.2.23:~> ls
---- Connecting to 192.168.2.23 (192.168.2.23) port 21
<--- 220 Welcome to Pure-FTPd [privsep] [TLS]
...
> USER feifei
<--- 331 User feifei OK. Password required
> PASS 123456
<--- 530 Login authentication failed

連線建立、TLS 協商正常,但在 PASS 階段被拒,代表認證模組未正確啟用或帳號資料庫不存在。

核心排查步驟

  1. 確認認證模組
    Pure-FTPd 支援多種認證(puredb、ldap、mysql、pam、unix)。執行:
    pure-ftpd --help | grep -i auth
    查看編譯支援哪些,啟動時需加 -l puredb:/etc/pure-ftpd/pureftpd.pdb 或 -l pam 等。
  2. 檢查帳號是否存在於對應資料庫
    若用 puredb:
    pure-pw list 應顯示 feifei。
    若無,需建立:
    pure-pw useradd feifei -u ftpuser -d /home/ftp/feifei
    pure-pw mkdb
  3. PAM 認證時 /etc/pam.d/pure-ftpd 設定
    #%PAM-1.0
    auth    required    pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
    auth    required    pam_shells.so
    auth    include     password-auth
    account include     password-auth
    session include     password-auth
    
    確保 pam_shells.so 允許的 shell 包含 /sbin/nologin(或將用戶 shell 改為 /bin/bash 測試)。
  4. SELinux / AppArmor 干擾
    getsebool -a | grep ftp 確認 ftpd_full_access=on;
    暫時設定 setenforce 0 測試。
  5. 被動模式端口未開放
    雖不影響登入,但會導致 ls、get 掛起。啟動參數加 -p 30000:30050 並開放防火牆。

快速修復腳本(針對 puredb 常見情況)

#!/bin/bash
# 建立系統帳號(不需登入 shell)
useradd -r -s /sbin/nologin -d /home/ftp/feifei -m ftpuser
mkdir -p /home/ftp/feifei
chown ftpuser:ftpuser /home/ftp/feifei

# 建立 pure-ftpd 虛擬帳號
echo -e "123456\n123456" | pure-pw useradd feifei -u ftpuser -d /home/ftp/feifei
pure-pw mkdb

# 重啟服務(假設用 xinetd)
service xinetd restart

驗證登入

lftp -u feifei,123456 192.168.2.23 -e "ls; quit"
# 或
ftp 192.168.2.23

逐項核對認證鏈路,530 錯誤通常在 5 分鐘內解決。

Copyright © Windows教程網 All Rights Reserved