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

Linux 新增/刪除 FTP 使用者並限制目錄權限 (vsftpd 實作)

編輯:Linux 教學

以 vsftpd 為例,建立僅能存取特定目錄的 FTP 帳號,禁止 SSH 登入。

一、建立使用者並指定家目錄

useradd -d /alidata/www/test test
passwd test

二、限制僅能 FTP,禁止 Shell 登入

usermod -s /sbin/nologin test   # 限制
usermod -s /bin/bash test       # 恢復

三、變更家目錄

usermod -d /new/path test

四、啟用 chroot 限制使用者無法跳出家目錄

編輯 /etc/vsftpd/vsftpd.conf:

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list

編輯 /etc/vsftpd/vsftpd.chroot_list,每行一個受限帳號:

test

重啟服務:/etc/init.d/vsftpd restart

五、允許使用者自行修改密碼(無 Shell)

usermod -s /usr/bin/passwd test

六、刪除 FTP 使用者

userdel test

七、安全性補充

  • 建議啟用 ssl_enable=YES 強制 FTPS 加密傳輸。
  • 設定 pasv_min_port/pasv_max_port 並對應開啟防火牆,解決被動模式連線問題。
  • 定期稽核 /var/log/vsftpd.log 或 /var/log/xferlog。

完成設定後,使用者僅能透過 FTP 存取指定目錄,大幅降低系統風險。

Copyright © Windows教程網 All Rights Reserved