vsftpd
Info
-
-
Probably the most secure and fastest
FTP server for UNIX-like systems.
Install on AWS EC2
sudo apt-get update
sudo apt-get install vsftpd -y
sudo vi /etc/vsftpd.conf
# 關閉 ipv6,這個問題卡很久,找很久才發現解決方式;不確定是不是 vsftpd 版本的問題
# https://www.centos.org/forums/viewtopic.php?t=52408
listen=YES
listen_ipv6=NO
# 允許本地用戶登錄
local_enable=YES
# 允許上傳
write_enable=YES
# 讀寫執行權限
local_umask=022
# 允許家目錄變為根目錄
chroot_local_user=YES
chroot_list_enable=YES
# 允許家目錄變為根目錄後擁有寫入權限
chroot_list_file=/etc/vsftpd.chroot_list
allow_writeable_chroot=YES
sudo useradd -m -s /usr/sbin/nologin test
sudo passwd test
# 之後輸入二次密碼
sudo vi /etc/shells
/usr/sbin/nologin
sudo vi /etc/vsftpd.chroot_list
sudo service vsftpd restart
使用 TSL 連線(SSL)
如果沒有憑證可以自簽
# 產生一個期限為 3650 天的自簽憑證
sudo openssl req -x509 -nodes -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem -days 3650 -newkey rsa:2048
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California
Locality Name (eg, city) []:Los Angeles
Organization Name (eg, company) [Internet Widgits Pty Ltd]:example.com
Organizational Unit Name (eg, section) []:Linux and Open Source
Common Name (e.g. server FQDN or YOUR name) []:example
Email Address []:info@example.com
修改 vsftpd 設定檔
sudo vi /etc/vsftpd.conf
#rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
rsa_cert_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
ssl_ciphers=HIGH
#rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
rsa_cert_file=/etc/letsencrypt/live/example.com/fullchain.pem
rsa_private_key_file=/etc/letsencrypt/live/example.com/privkey.pem
ssl_enable=YES
ssl_ciphers=HIGH
sudo service vsftpd restart
使用被動模式
-
-
我自己的理解是:當 Client 端在 NAT 架構下,使用被動模式比較不容易有問題(如果有錯請再告知)
-
修改 vsftpd 設定檔
sudo vi /etc/vsftpd.conf
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=50000
port_enable=YES
pasv_address=[Public IP]
# 使用 domain name 時
#pasv_address=[Domain Name]
#pasv_addr_resolve=YES<.code>
sudo service vsftpd restart
Reference