EC2をFTPS化する方法
色んなサイトを見ても純粋にEC2をFTPS化する記事がなくてめちゃくちゃハマったのでメモ
使用した物
- Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
- FileZilla
やり方
サーバー設定
-
インスタンスの立ち上げ
-
sshで接続
ssh -i Downloads/demo.pem ubuntu@<IPアドレス>
-
Ubuntuを更新
sudo apt update sudo apt upgrade
-
vsftpdをインストール
sudo apt install vsftpd
-
vsftpdを使ってFTPSをスタートさせるにはrootユーザーである必要があるのでユーザー変更
sudo -i
-
rootユーザーのパスワードを設定
passwd root
-
Certificateを保存すディレクトリの作成
mkdir /etc/ssl
-
Certificateの作成
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/ssl/vsftpd.pem -out /etc/ssl/vsftpd.pem
-
vsftpd.confの編集(FTPS化)
vim /etc/vsftpd.conf # 以下の設定を追加 rsa_cert_file=/etc/ssl/vsftpd.pem rsa_private_key_file=/etc/ssl/vsftpd.pem ssl_enable=YES allow_anon_ssl=NO force_local_data_ssl=YES force_local_logins_ssl=YES ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO require_ssl_reuse=NO ssl_ciphers=HIGH pasv_enable=Yes pasv_min_port=60000 pasv_max_port=60030 pasv_address=<EC2で作成したIPv4 Public IP>
-
rootでログインできる様にファイルを変更
vim /etc/ftpusers #この中のrootをコメントアウト
-
サービス開始
systemctl restart vsftpd systemctl status vsftpd
FileZilla
Tips
-
vsftpd.confの内容が合っているか確認する方法
/usr/sbin/vsftpd /etc/vsftpd.conf
-
もしこのエラーがでたら
500 OOPS: config file not owned by correct user, or not a file # このコマンドでオーナーを変える chown root:root /etc/vsftpd.conf
参考URL
https://www.youtube.com/watch?v=VZm8SoxgwXc
https://www.getpagespeed.com/server-setup/ssl-directory
https://dev.classmethod.jp/articles/ftps_on_centos7/
https://www.serverkaka.com/2018/08/enable-password-authentication-aws-ec2-instance.html