檔案傳輸協定(FTP)作為傳統的網路檔案共享方式,至今仍在許多應用場景中發揮重要作用。本文將詳細介紹如何在Linux環境下部署安全可靠的FTP檔案服務,採用業界廣泛認可的vsftpd服務軟體,幫助您快速建構高效能的檔案傳輸平台。
開始安裝前,請確保您的Linux系統滿足以下條件:
作業系統版本要求:
網路配置要求:
對於基於RPM的系統:
yum install -y vsftpd
systemctl enable vsftpd
對於Debian系系統:
apt-get update
apt-get install -y vsftpd
systemctl enable vsftpd
編輯設定檔/etc/vsftpd/vsftpd.conf
,建議進行以下調整:
# 禁止匿名存取
anonymous_enable=NO
# 啟用本地使用者登入
local_enable=YES
# 允許檔案上傳
write_enable=YES
# 限制使用者在主目錄
chroot_local_user=YES
allow_writeable_chroot=YES
# 日誌設定
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
建立專用FTP使用者群組和使用者:
groupadd ftpusers
useradd -g ftpusers -d /ftpdata -s /sbin/nologin ftpuser1
passwd ftpuser1
設定目錄權限:
mkdir -p /ftpdata
chown ftpuser1:ftpusers /ftpdata
chmod 750 /ftpdata
根據選擇的傳輸模式開放相應連接埠:
firewall-cmd --permanent --add-service=ftp
firewall-cmd --permanent --add-port=40000-41000/tcp
重新載入防火牆規則:
firewall-cmd --reload
啟動服務:
systemctl restart vsftpd
測試連線:
ftp localhost
透過以上步驟,您就可以在Linux系統上建置一個安全可靠的FTP檔案服務了。如需更高階的功能配置,可以參考vsftpd的官方文件進行進一步設定。
結語
透過本文的逐步指引,您已成功在Linux系統上建置了安全穩定的vsftpd服務。FTP作為經典的檔案傳輸解決方案,在內部檔案共享、網站內容管理等場景中仍具有重要價值。
聲明:此教程觀點為個人觀點供您參考,不代表阿里雲官方觀點!
Alibaba Cloud TC Content - January 14, 2022
Shevy - May 12, 2025
Alibaba Cloud TC Content - July 29, 2021
Alibaba Cloud TC Content - December 8, 2021
blog.acpn - November 10, 2023
Alibaba Cloud TC Content - January 14, 2022
Accelerate software development and delivery by integrating DevOps with the cloud
Learn MoreAlibaba Cloud Linux is a free-to-use, native operating system that provides a stable, reliable, and high-performance environment for your applications.
Learn MoreThis technology can assist realizing quantitative analysis, speeding up CT image analytics, avoiding errors caused by fatigue and adjusting treatment plans in time.
Learn MoreAn enterprise-level continuous delivery tool.
Learn More