1 views
実現する機能
自宅サーバーでWordPressを使っているため、FTPサーバーがなければテーマやプラグインのインストールもアップデートもできません。そこで、Vsftpdを導入して、インストールやアップデートができるようにしました。レンタルサーバーならこんな苦労は無いのですが、SSLでID&パスワードの暗号化通信ができたりするので自宅サーバーでも安心です。
Vsftpdの導入手順
以下の黒背景部分はGNOME端末を表示しています。紫色はキーボードから入力するコマンド(コピペした方が楽ですが、コマンドは覚えられません)、緑はコマンドや処理内容の説明、白は自動表示する部分、赤は注意書きです。
(1)Vsftpdのインストール
#vsftpdのインストール [root@ufuso ~]#yum -y install vsftpd インストール: vsftpd.x86_64 0:3.0.2-22.el7 完了しました! |
(2)Vsftpdの設定
#Vsftpdファイルの設定 [root@ufuso ~]#vi /etc/vsftpd/vsftpd.conf # Allow anonymous FTP? (Beware - allowed by default if you comment this out). #YESをNOに変更して匿名利用ーの禁止 anonymous_enable=NO # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #行頭の#を削除して、アスキーモードでのアップロードを許可 ascii_upload_enable=YES #行頭の#を削除して、アスキーモードでのダウンロードを許可 ascii_download_enable=YES # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) #行頭の#を削除して、ディレクトリより上層へ行けるユーザーを制限 chroot_local_user=YES #行頭の#を削除して、ディレクトリより上層へ行けるユーザーリスト使用 chroot_list_enable=YES # (default follows) #行頭の#を削除して、許可ユーザーのリストファイル指定 chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #行頭の#を削除して、ディレクトリ単位での一括転送を許可 ls_recurse_enable=YES #追記して、ホームディレクトリを/var/www/public_htmlとし、wwwより上層 には行けないよう設定 local_root=public_html #追記して、タイムスタンプに日本時間を使う use_localtime=YES #上層アクセスユーザーリストの作成 [root@ufuso ~]# vi /etc/vsftpd/chroot_list #上層アクセスユーザーに自分のユーザー名(tuは例示)のみ登録 tu #Vsftpdの起動 [root@ufuso ~]# systemctl start vsftpd #Vsftpdの自動起動設定 [root@ufuso ~]# systemctl enable vsftpd Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service. |
(3)SSL/TSLの設定
#certsディレクトリへ移動 [root@ufuso ~]#cd /etc/pki/tls/certs #サーバー証明書の作成 [root@ufuso certs]# openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/vsftpd.pem -out /etc/pki/tls/certs/vsftpd.pem Generating a 1024 bit RSA private key ........................++++++ .....++++++ writing new private key to '/etc/pki/tls/certs/vsftpd.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- #サーバーのある国名を入力してエンター・キーを押す(以下同じ) Country Name (2 letter code) [XX]:JP #都道府県名 State or Province Name (full name) []:Okinawa #市区町村名 Locality Name (eg, city) [Default City]:Naha #組織名(ホスト名も可) Organization Name (eg, company) [Default Company Ltd]:ShikakiraCS #部課名(無入力もOK) Organizational Unit Name (eg, section) []: #ホスト名 Common Name (eg, your name or your server's hostname) []:ufuso.dip.jp #障害時等の連絡先メールアドレス Email Address []:tu@ufuso.dip.jp #ファイルへの外部アクセス禁止 [root@ufuso certs]# chmod 600 vsftpd.pem #vsftpdファイルに設定追加 [root@ufuso certs]# vi /etc/vsftpd/vsftpd.conf 以下を最終行に追記 #サーバー証明書を指定 rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem #SSLの有効化 ssl_enable=YES #通信のSSL使用を強制しない force_local_data_ssl=NO #ユーザー認証のSSL使用を強制しない force_local_logins_ssl=NO ※SSL使用を強制するとWordPressで「wp-contentディレクトリが見つかりません」 というエラーが出る #vsftpdの再起動 [root@ufuso certs]# systemctl restart vsftpd #SELinuxが有効な場合には、フルアクセス許可を設定 [root@ufuso ~]# setsebool -P allow_ftpd_full_access 1 |
コメントを残す