在ubuntu伺服器上構建一個FTP服務
阿新 • • 發佈:2020-08-04
目的是使用VSFTPD守護程式在Ubuntu 18.04 Bionic Beaver上設定FTP伺服器。
作業系統:-Ubuntu 18.04 Bionic Beaver
軟體:-vsftpd:版本3.0.3或更高版本
需要有root許可權
sudo apt-get install vsftpd
直接先安裝vsftp
配置的時候先備份一份配置檔案
sudo mv /etc/vsftpd.conf /etc/vsftpd.conf_orig
然後編輯配置檔案 用vi 或者nano 隨意
sudo nano /etc/vsftpd.conf
建議您從下面的基本FTP伺服器配置開始,確認它正在執行,然後對其進行微調以適合您的特定環境需求:
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
pasv_enable=Yes
pasv_min_port=10000
pasv_max_port=10100
allow_writeable_chroot=YES
將上述FTP配置行插入/etc/vsftpd.conf
檔案中。
如果你啟動了防火牆 需要開啟一下埠ufw
sudo ufw allow from any to any port 20,21,10000:10100 proto tcp
然後我們重啟一下服務
sudo service vsftpd restart
然後建立ftp使用者
$ sudo useradd -m ftpuser $ sudo passwd ftpuser Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
然後建立成功就可以使用file zilla 這樣的GUI工具進行連線使用了。
到時候上傳檔案就會發現在那個資料夾下這個使用者的資料夾裡了。