Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

FTP 530 Permission Denied:根因其實是帳號密碼錯,別再誤診了

編輯:Linux 系統常見問題解答

FileZilla 彈出 530 Permission denied,第一反應以為是防火牆、SELinux、vsftpd 配置錯?實測 90% 以上案例純粹是 帳號或密碼輸入錯誤(含儲存的舊密碼未更新)。本文 3 分鐘教你精準定位、徹底解決。

典型錯誤日誌

狀態: 連接到 192.168.1.100:21...
回應: 220 Welcome to FTP service.
命令: USER ftpuser111
回應: 331 Password required for ftpuser111
命令: PASS ************
回應: 530 Permission denied
錯誤: 嚴重錯誤:無法連接到伺服器

快速排查清單

步驟指令/動作預期結果
1. 確認帳號存在grep ^ftpuser111: /etc/passwd輸出使用者資訊
2. 確認密碼正確echo "ftpuser111:newpass" | chpasswd 重設密碼無報錯
3. 確認 vsftpd 允許本地登入grep local_enable /etc/vsftpd.conflocal_enable=YES
4. 確認未被 user_list/ftpusers 封鎖grep -E 'userlist_deny|userlist_enable' /etc/vsftpd.confuserlist_deny=NO 且帳號在 user_list 中
5. 測試本地登入ftp localhost → 輸入帳密230 Login successful
6. 測試遠端登入FileZilla/WinSCP 重新輸入(勿用儲存密碼)連線成功

常見誤區與真相

誤區真相
「530 是防火牆擋了」防火牆擋的是 連線建立(SYN),不會讓你進到 USER/PASS 交互
「SELinux 導致 530」SELinux 通常導致 500 OOPS: priv_sock_get_cmd 或目錄掛載失敗,非 530
「vsftpd.conf 沒改對」配置錯通常報 500 OOPS、421 Service not available,而非 530
「被動模式/主動模式問題」模式錯會卡在 LIST/MLSD/資料傳輸階段,非認證階段

一鍵重建帳號腳本(適用 vsftpd + 系統帳號)

#!/bin/bash
# recreate_ftp_user.sh
USER=$1
PASS=$2
[ -z "$USER" -o -z "$PASS" ] && { echo "Usage: $0  "; exit 1; }

# 1. 刪除舊帳號(含家目錄)
userdel -r "$USER" 2>/dev/null

# 2. 建立新帳號,指定家目錄、禁用 shell
useradd -m -d /home/$USER -s /sbin/nologin "$USER"
echo "$USER:$PASS" | chpasswd

# 3. 確保 vsftpd 允許
grep -q '^local_enable=YES' /etc/vsftpd.conf || sed -i 's/^#*local_enable=.*/local_enable=YES/' /etc/vsftpd.conf
grep -q '^write_enable=YES' /etc/vsftpd.conf || sed -i 's/^#*write_enable=.*/write_enable=YES/' /etc/vsftpd.conf

# 4. 加入 user_list(白名單模式)
echo "$USER" >> /etc/vsftpd/user_list
sort -u /etc/vsftpd/user_list -o /etc/vsftpd/user_list

# 5. 重啟服務
systemctl restart vsftpd

echo "FTP user $USER recreated. Test: ftp localhost"

驗證步驟

# 本地測試
ftp localhost
# Connected to localhost.
# Name: ftpuser111
# Password: ********
# 230 Login successful.
# ftp> quit

# 遠端測試(FileZilla)
# 協定: FTP - File Transfer Protocol
# 加密: 僅使用純文字 FTP(或 Require explicit FTP over TLS)
# 登入類型: 正常
# 用戶/密碼: 手動輸入(勿用儲存)

結語: 看到 530 Permission denied,先別動防火牆、別查 SELinux、別改 vsftpd.conf。**重設密碼、手動輸入、本地測試** 三步走,省下兩小時排查時間。真正的配置錯誤通常長得不像 530。

Copyright © Windows教程網 All Rights Reserved