Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
Lightsail インスタンスに FTP サーバーと FTP ユーザーを設定する方法を教えてください。
Amazon Linux 2、CentOS、Ubuntu、または Debian を実行している Amazon Lightsail インスタンスにファイル転送プロトコル (FTP) サーバーと FTP ユーザーをセットアップしたいと考えています。
解決策
**注:**FTP は、すべてのデータとパスワードをプレーンテキストとして送信します。SSH ファイル転送プロトコル (SFTP) は、インスタンスに接続してデータを送信する、より安全な方法です。SFTP の使用方法については、「SFTP を使用して Amazon Lightsail の Linux または Unix インスタンスに接続する」をご参照ください。
FTP サーバーと FTP ユーザーの設定
1. VSFTPD パッケージをインストールするには、次のコマンドを実行します。
Amazon Linux 2 と CentOS:
sudo yum install vsftpd -y
Ubuntu と Debian:
sudo apt install vsftpd -y
パッケージが利用できないというエラーが表示された場合は、次のコマンドを実行してパッケージリストを更新します。
sudo apt update -y
2. vsftpd.config ファイルを編集して、環境に合わせて変数を更新します。
vsftpd.config ファイルの場所は、オペレーティングシステムによって異なります。
- Amazon Linux 2 と CentOS: /etc/vsftpd/vsftpd.conf
- Debian と Ubuntu: /etc/vsftpd.conf
次の例では、ユースケースに合わせて変数を更新します。次のパラメータは、すべてのオペレーティングシステムに共通です。
anonymous_enable=NO local_enable=YES write_enable=YES dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=NO xferlog_std_format=YES chroot_local_user=YES allow_writeable_chroot=YES listen=YES pam_service_name=vsftpd userlist_enable=YES userlist_deny=NO listen_port=10021 pasv_enable=YES pasv_min_port=21000 pasv_max_port=21999 pasv_addr_resolve=NO
注:ポート 21 は FTP のデフォルトポートです。ただし、セキュリティ上の理由から、前の例ではカスタムポート 10021 が FTP のポートとして使用されています。ポートをカスタマイズするには、listen_port を目的のポートに変更し、connect_from_port_20 をNO に設定します。FTP に使用する予定のポートがインスタンスのファイアウォールで有効になっているかどうかご確認ください。前の例では、ポート 10021 とポート 21000-21999 がカスタムファイアウォールと Lightsail ファイアウォール で有効になっています。また、listen パラメータと listen_ipv6 パラメータを同時にファイルに含めることはできません。設定ファイルを更新して、1 つだけが YES になるようにします。
次のパラメータは、オペレーティングシステムに固有です。前の例に加えて、お使いのオペレーティングシステムに合わせて次の変数を編集します。
Amazon Linux 2 と CentOS
chroot_list_file=/etc/vsftpd/chroot_listuserlist_file=/etc/vsftpd/user_list
Debian と Ubuntu:
chroot_list_file=/etc/vsftpd.chroot_listuserlist_file=/etc/vsftpd.userlist
3. 次のコマンドを実行して FTP ユーザーを追加します。
sudo useradd -m ftp_user
**注:**前の例では、ftp_user を任意のユーザー名に置き換えてください。
4. 次のコマンドを実行して、ユーザーのパスワードを作成します。
sudo passwd ftp_user
5. 次のコマンドを実行して、/home/ftp_user ファイルの所有者を変更します。このコマンドは、ftp_user をファイルの所有者にします。
sudo chown ftp_user:ftp_user -R /home/ftp_user/
6. 次のコマンドを実行して、新しいユーザーを vsftpd user_list に追加します。-a フラグを使用してファイルに追加します。
Amazon Linux 2 と CentOS
sudo echo "ftp_user" | sudo tee -a /etc/vsftpd/user_list
Debian と Ubuntu
次のコマンドを実行して、userlist ファイルを作成し、新しいユーザーをファイルに追加します。
sudo echo "ftp_user" | sudo tee -a /etc/vsftpd.userlist
7. vsftpd サービスを再起動します。
sudo systemctl restart vsftpd
8. FTP サーバーに接続します。次の例では Filezilla のプレーン FTP を使用しています。
Status: Connecting to 54.xxx.xxx.x2:10021... Status: Connection established, waiting for welcome message... Status: Plain FTP is insecure. Please switch to FTP over TLS. Status: Logged in Status: Retrieving directory listing... Status: Server sent passive reply with unroutable address. Using server address instead. Status: Calculating timezone offset of server... Status: Timezone offset of server is 0 seconds. Status: Directory listing of "/" successful Status: Connecting to 54.xxx.1xx.52:10021... Status: Connection established, waiting for welcome message... Status: Plain FTP is insecure. Please switch to FTP over TLS. Status: Logged in Status: Starting upload of C:\Users\Administrator\Documents\FTPtest.txt Status: Server sent passive reply with unroutable address. Using server address instead. Status: File transfer successful, transferred 10 bytes in 1 second Status: Retrieving directory listing of "/"... Status: Server sent passive reply with unroutable address. Using server address instead. Status: Directory listing of "/" successful
FTP サーバー設定のトラブルシューティング
vsftpd.conf 設定ファイルのパラメータが正しく設定されていないと、FTP サーバーが起動しない可能性があります。この場合は、次のコマンドを実行して、正しく構成されていないオプションを確認してください。
Amazon Linux 2 と CentOS
sudo /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Debian と Ubuntu
sudo /usr/sbin/vsftpd /etc/vsftpd.conf
関連するコンテンツ
- 質問済み 3年前
