LoginSignup
3
3

More than 3 years have passed since last update.

EC2をFTPS化する方法

Last updated at Posted at 2020-04-23

EC2をFTPS化する方法

色んなサイトを見ても純粋にEC2をFTPS化する記事がなくてめちゃくちゃハマったのでメモ

使用した物

  • Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
  • FileZilla

やり方

サーバー設定

  • インスタンスの立ち上げ

    セキュリティグループの設定例
    SnapCrab_NoName_2016-4-25_23-4-43_No-00.png

  • 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をコメントアウト
    

    Screen Shot 2020-04-22 at 6.07.45 PM.png

  • サービス開始

    systemctl restart vsftpd
    systemctl status vsftpd
    

FileZilla

Screen Shot 2020-04-22 at 6.10.28 PM.png

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

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3