【FTPS】【CentOS7】【RedHat7】FTPS サーバの構築と設定をしてクライアントPCからファイルを転送する手順

公開日時:2019年03月16日 / 最終更新日時:2019年03月22日

Linux 系(RedHat 7 系)FTPS サーバの構築と設定をしてクライアント PC からファイルを転送する手順を解説します。

ファイル転送なら FTP(File Transfer Protocol)が有名ですが、インターネット経由でデータを転送するとデータの中身が丸見えになってしまうため、FTPS(File Transfer Protocol over SSL/TLS)でデータを暗号化してデータを転送します。

 

FTP の説明です。

【初心者向け】FTPとは?

 

 

 

FTPS(File Transfer Protocol over SSL/TLS)とは?

FTPS は「File Transfer Protocol over SSL/TLS」の略です。

プロトコル名に「SSL/TLS」の文字が入っていることからも SSL/TLS プロトコルを利用してデータを暗号化します。 

 

【レンタルサーバー】 ファイルをアップロードする時は FTP より SCP や SFTP を使う

 

 

 

FTP と SFTP と FTPS の違い

 

FTP と SFTP と FTPS それぞれが使用するポート番号

 

 

 

FTPS サーバの設計

 

 

 

FTPS サーバの構築手順

大まかに言えば、以下のような構築手順になります。

  1. Amazon EC2 インスタンスの作成
  2. 自己署名証明書(オレオレ証明書)の作成
  3. Elastic IP の取得
  4. Route53 への登録
  5. FTPツールのインストールおよび設定
  6. 動作検証
  7. トラブルシューティング

 

 

 

 

Amazon EC2 インスタンスの作成

Amazon EC2 インスタンスは既存のインスタンスを使用します。

[ec2-user@redhat7 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[ec2-user@redhat7 ~]$

 

 

 

自己署名証明書(オレオレ証明書)の作成

次に自己署名証明書を作成します。

 

以下、自己署名証明書の作成手順の参考です。

 

【Linux】【CentOS6】Apache で「自己証明書(オレオレ証明書)」を作成して HTTPS でアクセスできるようにする手順

 

 

自己署名証明書の作成作業

今回は以下の openssl コマンドで /etc/vsftpd ディレクトリに一気に自己署名証明書(オレオレ証明書)を作成します。

[root@redhat7 ~]# openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem

 

■オプションの解説

 

 

以下のようにファイルが作成されます。

[root@redhat7 vsftpd]# ls -l 
total 48 
-rw-------. 1 root root  125 Jun 21  2018 ftpusers 
-rw-------. 1 root root  361 Jun 21  2018 user_list 
-rw-r--r--. 1 root root 6359 Mar 16 04:09 vsftpd.conf 
-rw-------. 1 root root 5116 Jun 21  2018 vsftpd.conf.org 
-rw-r--r--. 1 root root 1954 Mar 16 02:07 vsftpd.pem 
[root@redhat7 vsftpd]#

 

 

 

■vsftpd.pem ファイルの中身

vsftpd.pem ファイルの中身は以下のように「秘密鍵」「サーバ証明書」が入っています。

[root@redhat7 vsftpd]# cat vsftpd.pem
-----BEGIN PRIVATE KEY----- ← BEGIN PRIVATE KEY で始まるので秘密鍵です。

MxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxM
O8zJVLwFtZv6MKvcDj5xsPzhx1zyPA2yHjJT2ZYyco0ASbz2Gld80mv3rhFqhLt+
IVbnslL4go3cnp9oe/RBrwajnq++WNRolzzf+fCJuqmACMh+fxPSltzE5BoCYmx4
+ygFMvJhaoXTr+qT7KrOXVqP5Ea9AgMBAAECgYEArrPSC1fDohzKTWayhr/OV0nx
M5HFMmQwkFV2/dgltHJcWnwUqcpuEZxgoYEMs7UozA6MAH+QBMSdxTKfBrtyetAT
E7P4MmY8f7IppfpZ/afrlrTiZrNTP5azQGaS+9fjyuqg9bvOrK3s4DsloiDm0E4J
S+SNsZNWALfmanDdCWECQQDszvgGRXl0kNVLHUHG9GqWvCAGn/Akpp7m7L/hG/y8
ER1kr8jRTJQQbIIPeZDrGXd/TUx4wG/c598/1FFStfFZAkEA1ZNvyAuT2umCR8tm
3n557NDZU9a6VRcLUgiMYBBnDGHkCtbVanLF4AlwlLVuamPT8UxlwUCif2WkMany
zCkQBQJAfqXqTCBX5pmXGUcaaLdLUjZmwmRDYLakAUjZDiGTt1lH6ROCST21als9
69zOPo4uNK04mtQAf5qa8V4x6BRacQJAPaeFQmONOEnmkSE3vg0W13Vm95vqSHwR
iYnsNCMoDFwJ/9MK4uLlGoq/FD7X9CCDY4ohactl3Y8S+j9MVwGXnQJAOAgjxjni
Zbgow9jdQiE0LpfgNNaniI6BzQGvuwsmP9ozXdIpNcZqRbQqcOLgmz2MB0H6K+ft
rK5yTvN5ufaiRQ==
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE----- ← BEGIN CERTIFICATE で始まるので秘密鍵です。
MxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxD
VQQGEwJKUDEOMAwGA1UECAwFVE9LWU8xDjAMBgNVBAcMBVRPS1lPMREwDwYDVQQK
DAhUZXN0IEx0ZDELMAkGA1UECwwCSVQxEzARBgNVBAMMCmJveC1jbS5jb20xHDAa
BgkqhkiG9w0BCQEWDXRlc3RAdGVzdC5jb20wHhcNMTkwMzE2MDIwNzQwWhcNMTkw
NDE1MDIwNzQwWjCBgDELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRPS1lPMQ4wDAYD
VQQHDAVUT0tZTzERMA8GA1UECgwIVGVzdCBMdGQxCzAJBgNVBAsMAklUMRMwEQYD
VQQDDApib3gtY20uY29tMRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRlc3QuY29tMIGf
MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFkJacbVoZwVG+jDvMyVS8BbWb+jCr
3A4+cbD84cdc8jwNsh4yU9mWMnKNAEm89hpXfNJr964RaoS7fiFW57JS+IKN3J6f
aHv0Qa8Go56vvljUaJc83/nwibqpgAjIfn8T0pbcxOQaAmJsePsoBTLyYWqF06/q
k+yqzl1aj+RGvQIDAQABo1AwTjAdBgNVHQ4EFgQUrUvnko5psnuv41LUriNS9hji
hkwwHwYDVR0jBBgwFoAUrUvnko5psnuv41LUriNS9hjihkwwDAYDVR0TBAUwAwEB
/zANBgkqhkiG9w0BAQsFAAOBgQC8WSmuwGQSnoh7iv667N9QtsOZL4vck7QEGr7X
1a+sWD7LBKTjk7kc2kqWk/1bDiiWGfPRzGT86TXGdm2+ElPL0INUCZlO5+OOINuS
G98aWho+ucQRsO9qUFKsWdqsjlrqx+GvgV+Pygzb3x7uzSgwflXDRkcr98bYeA0T
dVMgvg==
-----END CERTIFICATE-----
[root@redhat7 vsftpd]#

 

 

OpenSSLのバージョン確認

エラーが出力された場合は、以下の OpelSSL のバージョン確認のコマンド(openssl version)を実行してみます。

もしエラーになった場合は、OpenSSL がインストールされていないため、「yum install openssl」コマンドでインストールします。

[root@redhat7 ~]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@redhat7 ~]#

 

 

 

Elastic IP の取得

通常、EC2 インスタンスとドメイン設定する場合、ELB(Elastic Load Balancer)にドメインを結びつけますが、今回は FTP サーバー 1 台構成で構築するために、ELB ではなく EC2 インスタンスに直接ドメインを結びつけます。

そのため事前に「Elastic IP」を取得し、「Elastic IP」を EC2 インスタンスに割り当てます。

「Elastic IP」を取得しないと、EC2 インスタンスの停止・起動のタイミングでグローバル IP が変わる可能性があります。

 

 

 

AWS 管理コンソールより「サービス」「ネットワーキング&コンテンツ配信」「VPC」を選択します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

VPC ダッシュボードに移動したら、左側ペインより「Elastic IP」をクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

「新しいアドレスの割り当て」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

下図のような確認画面が表示されたら「割り当て」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

「Elastic IP」が割り当てられたことを確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

アドレスの関連付け

次に取得した「Elastic IP」を FTPS サーバーとしたい EC2 インスタンスに関連付けます。

※ELB を経由しないため、直接 EC2 インスタンスに関連付けします。

 

「Elastic IP」の画面より、関連付けをしたい「Elastic IP」を選択して「アクション」「アドレスの関連付け」をクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

下図のように関連付けをしたい「EC2 インスタンス」「プライベート IP」を選択して「関連付け」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

「新しいアドレスの関連付けが成功しました」のメッセージが表示されることを確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

下図のように EC2 インスタンスに「Elastic IP」が割り当てられていることを確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

独自ドメインを Route 53 へ登録

次に「お名前.com」で取得した独自ドメイン Amazon Route 53 に登録します。

 

【AWS】Route53 に「お名前.com」取得の独自ドメインを登録して Amazon SES(Simple Email Service)で SMTP プロトコルでメールを送信する手順

 

【AWS】Route53に「お名前.com」取得の独自ドメインを登録してSES(Simple Email Service)で無料でメールを受信する手順

 

 

独自ドメインを新規登録する

AWS の管理コンソールにログインし「サービス」「ネットワーキング&コンテンツ配信」「Route 53」をクリックします。

【SFTP】【CentOS7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

ドメインが登録されていない場合は、下図のように「Get started now」ボタンが表示されるのでクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

「Create Hosted Zone」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

もう一度「Create Hosted Zone」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

下図のように設定して「Create」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

ドメインを作成すると下図のようにネームサーバーが表示されるので、後程この 4 つのネームサーバーを「お名前.com」に登録します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

「Create Record Set」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

下図のように設定して「Create」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

下図のように「Elastic IP」で A レコードが作成されていること確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

お名前.com にネームサーバーを登録する

「お名前.com Navi」にログインします。

 

https://www.onamae.com/navi/login/?btn_id=navi_login_onamaetop_header_newdesign&ab=navilogin_other_abflow

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

「お名前.com Navi」にログインしたら、メニューより「ドメイン一覧」をクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

対象ドメインのネームサーバーの「変更する」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

下図のように確認画面が表示されるので「登録情報は正しいので、手続きを進める」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

「他のネームサーバーを利用」タブをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

先ほどの Route 53 で表示されたネームサーバー 4 つをすべて入力し「確認画面へ進む」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

下図のように確認画面が表示されるので「設定する」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

 

下図のように「ネームサーバーの変更 完了」画面が表示されることを確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

コマンドプロンプトを起動して「nslookup」コマンドで動作確認をします。

C:\Users\xxxx>nslookup xxxx.com 8.8.8.8 
サーバー:  google-public-dns-a.google.com 
Address:  8.8.8.8 
 
権限のない回答: 
名前:    xxxx.com 
Address:  157.xxx.xxx.xxx 
 
 
C:\Users\xxxx> 

 

 

以上でドメインの登録及び設定は完了です。

 

 

FTPツール(vsftpd)のインストールおよび設定

Linux(RedHat 7)に FTP ツール(vsftpd)をインストールします。

 

FTPツール(vsftpd)のインストール

最初に root アカウントにスイッチします。

[ec2-user@redhat7 ~]$ sudo su -
Last login: Sun Mar 10 12:43:19 UTC 2019 on pts/0
[root@redhat7 ~]#

 

 

yum コマンドで vsftpd をインストールします。

[root@redhat7 ~]# yum install vsftpd

 

 

FTPツール(vsftpd)のコンフィグファイル(/etc/vsftpd/vsftpd.conf)の編集

次に vsftpd のコンフィグファイル(/etc/vsftpd/vsftpd.conf)を設定します。

 

最初に設定ファイルをバックアップします。

[root@redhat7 ~]# cp -ip /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.org 
[root@redhat7 ~]# ls -lh /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.org 
-rw-------. 1 root root 5.0K Jun 21  2018 /etc/vsftpd/vsftpd.conf 
-rw-------. 1 root root 5.0K Jun 21  2018 /etc/vsftpd/vsftpd.conf.org 
[root@redhat7 ~]#

 

 

 

vi コマンドで「/etc/vsftpd/vsftpd.conf」を編集します。

[root@redhat7 vsftpd]# vi /etc/vsftpd/vsftpd.conf

 

SSLを有効化します。

# SSLを有効化します。
ssl_enable=YES

 

 

SSLv2 と SSLv3 は使用しません。

# SSLv2とSSLv3は使用しません。(明示的にNOにします)
ssl_sslv2=NO
ssl_sslv3=NO

 

 

TLS を使用する設定にしますが、TLS 1.0 は使用せずに、TLS 1.1 と TLS 1.2 のみ使用します。

# TLSを使います。
# TLS 1.0 でのアクセスは許可しません。
ssl_tlsv1=NO
# TLS 1.1 でのアクセスは許可します。
ssl_tlsv1_1=YES
# TLS 1.2 でのアクセスは許可します。
ssl_tlsv1_2=YES

 

SSL での anonymous 接続を許可しません。

allow_anon_ssl=NO

 

 

ローカルユーザー接続でログインとデータ転送に SSL を使用します。

※ローカルユーザー接続とは、FTP サーバに存在するアカウント(test001とかtest3とか)でアクセスすることを言います。

# ローカルユーザー接続でログインとデータ転送に SSL を使用します。
force_local_logins_ssl=YES
force_local_data_ssl=YES

 

 

証明書の場所を指定します。

サーバー証明書の情報も、秘密鍵(プライベートキー)の情報も「/etc/vsftpd/vsftpd.pem」ファイルにまとめています。

# 証明書の場所を指定します。
rsa_cert_file=/etc/vsftpd/vsftpd.pem
rsa_private_key_file=/etc/vsftpd/vsftpd.pem

 

 

 

anonymous 接続(アノニマス接続)を許可しません。

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
#anonymous_enable=YES
anonymous_enable=NO

 

 

IPv4 アドレスに対してのみ Listen します。

IPv6 アドレスからは Listen しません。

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
# IPv4のみListenします。
#listen=NO
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
# IPv6はListenしません。
listen_ipv6=NO

 

 

 

■今回編集した結果の「/etc/vsftpd/vsftpd.conf」ファイル

[root@redhat7 vsftpd]# cat vsftpd.conf 
# Example config file /etc/vsftpd/vsftpd.conf 

# The default compiled in settings are fairly paranoid. This sample file 
# loosens things up a bit, to make the ftp daemon more usable. 
# Please see vsftpd.conf.5 for all compiled in defaults. 

# READ THIS: This example file is NOT an exhaustive list of vsftpd options. 
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's 
# capabilities. 

# Allow anonymous FTP? (Beware - allowed by default if you comment this out). 
#anonymous_enable=YES 
anonymous_enable=NO 

# Uncomment this to allow local users to log in. 
# When SELinux is enforcing check for SE bool ftp_home_dir 
local_enable=YES 

# Uncomment this to enable any form of FTP write command. 
write_enable=YES 

# Default umask for local users is 077. You may wish to change this to 022, 
# if your users expect that (022 is used by most other ftpd's) 
local_umask=022 

# Uncomment this to allow the anonymous FTP user to upload files. This only 
# has an effect if the above global write enable is activated. Also, you will 
# obviously need to create a directory writable by the FTP user. 
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access 
#anon_upload_enable=YES 

# Uncomment this if you want the anonymous FTP user to be able to create 
# new directories. 
#anon_mkdir_write_enable=YES 

# Activate directory messages - messages given to remote users when they 
# go into a certain directory. 
dirmessage_enable=YES 

# Activate logging of uploads/downloads. 
xferlog_enable=YES 

# Make sure PORT transfer connections originate from port 20 (ftp-data). 
connect_from_port_20=YES 

# If you want, you can arrange for uploaded anonymous files to be owned by 
# a different user. Note! Using "root" for uploaded files is not 
# recommended! 
#chown_uploads=YES 
#chown_username=whoever 

# You may override where the log file goes if you like. The default is shown 
# below. 
#xferlog_file=/var/log/xferlog 
xferlog_file=/var/log/xferlog 

# If you want, you can have your log file in standard ftpd xferlog format. 
# Note that the default log file location is /var/log/xferlog in this case. 
xferlog_std_format=YES 
 

# You may change the default value for timing out an idle session. 
#idle_session_timeout=600 

# You may change the default value for timing out a data connection. 
#data_connection_timeout=120 

# It is recommended that you define on your system a unique user which the 
# ftp server can use as a totally isolated and unprivileged user. 
#nopriv_user=ftpsecure 

# Enable this and the server will recognise asynchronous ABOR requests. Not 
# recommended for security (the code is non-trivial). Not enabling it, 
# however, may confuse older FTP clients. 
#async_abor_enable=YES 

# 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. The vsftpd.conf(5) man page explains 
# the behaviour when these options are disabled. 
# 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 fully customise the login banner string: 
#ftpd_banner=Welcome to blah FTP service. 

# You may specify a file of disallowed anonymous e-mail addresses. Apparently 
# useful for combatting certain DoS attacks. 
#deny_email_enable=YES 
# (default follows) 
#banned_email_file=/etc/vsftpd/banned_emails 

# 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 

# When "listen" directive is enabled, vsftpd runs in standalone mode and 
# listens on IPv4 sockets. This directive cannot be used in conjunction 
# with the listen_ipv6 directive. 
# IPv4のみListenします。 
#listen=NO 
listen=YES 

# This directive enables listening on IPv6 sockets. By default, listening 
# on the IPv6 "any" address (::) will accept connections from both IPv6 
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 
# sockets. If you want that (perhaps because you want to listen on specific 
# addresses) then you must run two copies of vsftpd with two configuration 
# files. 
# Make sure, that one of the listen options is commented !! 
#listen_ipv6=YES 
# IPv6はListenしません。 
listen_ipv6=NO 
 
pam_service_name=vsftpd 
userlist_enable=YES 
tcp_wrappers=YES 
 
# SSLを有効化します。 
ssl_enable=YES 
# SSLv2とSSLv3は使用しません。 
#ssl_sslv2=YES 
#ssl_sslv3=YES 
# TLSを使います。 
# TLS 1.0 でのアクセスは許可しません。 
ssl_tlsv1=NO 
# TLS 1.1 でのアクセスは許可します。 
ssl_tlsv1_1=YES 
# TLS 1.2 でのアクセスは許可します。 
ssl_tlsv1_2=YES 
allow_anon_ssl=NO 
# ノンセキュアなFTPは使用させず、SSLを強制します。 
force_local_logins_ssl=YES 
force_local_data_ssl=YES 
# 証明書の場所を指定します。 
rsa_cert_file=/etc/vsftpd/vsftpd.pem 
rsa_private_key_file=/etc/vsftpd/vsftpd.pem 

 

 

vsftpd サービスの起動

コンフィグの編集が完了したら vsftpd サービスを起動します。

[root@redhat7 log]# systemctl start vsftpd.service ← vsftpd サービスを起動します。 
[root@redhat7 log]# systemctl status vsftpd.service ← vsftpd サービスのステータスを確認します。
● vsftpd.service - Vsftpd ftp daemon 
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) 
   Active: active (running) since Sat 2019-03-16 04:09:08 UTC; 2s ago 
  Process: 5207 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) 
 Main PID: 5208 (vsftpd) 
   CGroup: /system.slice/vsftpd.service 
           mq5208 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
 
Mar 16 04:09:08 redhat7 systemd[1]: Stopped Vsftpd ftp daemon. 
Mar 16 04:09:08 redhat7 systemd[1]: Starting Vsftpd ftp daemon... 
Mar 16 04:09:08 redhat7 systemd[1]: Started Vsftpd ftp daemon. 
[root@redhat7 log]#

 

 

FTPS での「アクティブモード」と「パッシブモード」の違い

FTP に「アクティブモード」「パッシブモード」がありますが、FTPS にも「アクティブモード」「パッシブモード」があります。

 

【FTPの基本】 「アクティブモード」と「パッシブモード」の違いとは?

 

 

 

 

 

 

 

以下の vsftpd.conf ファイルで「パッシブモード」で接続される

今回設定した以下の vsftpd.conf ファイルの場合、パッシブモードで FTPS サーバーに接続されていました。

 

■今回編集した結果の「/etc/vsftpd/vsftpd.conf」ファイル

[root@redhat7 vsftpd]# cat vsftpd.conf 
# Example config file /etc/vsftpd/vsftpd.conf 

# The default compiled in settings are fairly paranoid. This sample file 
# loosens things up a bit, to make the ftp daemon more usable. 
# Please see vsftpd.conf.5 for all compiled in defaults. 

# READ THIS: This example file is NOT an exhaustive list of vsftpd options. 
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's 
# capabilities. 

# Allow anonymous FTP? (Beware - allowed by default if you comment this out). 
#anonymous_enable=YES 
anonymous_enable=NO 

# Uncomment this to allow local users to log in. 
# When SELinux is enforcing check for SE bool ftp_home_dir 
local_enable=YES 

# Uncomment this to enable any form of FTP write command. 
write_enable=YES 

# Default umask for local users is 077. You may wish to change this to 022, 
# if your users expect that (022 is used by most other ftpd's) 
local_umask=022 

# Uncomment this to allow the anonymous FTP user to upload files. This only 
# has an effect if the above global write enable is activated. Also, you will 
# obviously need to create a directory writable by the FTP user. 
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access 
#anon_upload_enable=YES 

# Uncomment this if you want the anonymous FTP user to be able to create 
# new directories. 
#anon_mkdir_write_enable=YES 

# Activate directory messages - messages given to remote users when they 
# go into a certain directory. 
dirmessage_enable=YES 

# Activate logging of uploads/downloads. 
xferlog_enable=YES 

# Make sure PORT transfer connections originate from port 20 (ftp-data). 
connect_from_port_20=YES 

# If you want, you can arrange for uploaded anonymous files to be owned by 
# a different user. Note! Using "root" for uploaded files is not 
# recommended! 
#chown_uploads=YES 
#chown_username=whoever 

# You may override where the log file goes if you like. The default is shown 
# below. 
#xferlog_file=/var/log/xferlog 
xferlog_file=/var/log/xferlog 

# If you want, you can have your log file in standard ftpd xferlog format. 
# Note that the default log file location is /var/log/xferlog in this case. 
xferlog_std_format=YES 
 

# You may change the default value for timing out an idle session. 
#idle_session_timeout=600 

# You may change the default value for timing out a data connection. 
#data_connection_timeout=120 

# It is recommended that you define on your system a unique user which the 
# ftp server can use as a totally isolated and unprivileged user. 
#nopriv_user=ftpsecure 

# Enable this and the server will recognise asynchronous ABOR requests. Not 
# recommended for security (the code is non-trivial). Not enabling it, 
# however, may confuse older FTP clients. 
#async_abor_enable=YES 

# 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. The vsftpd.conf(5) man page explains 
# the behaviour when these options are disabled. 
# 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 fully customise the login banner string: 
#ftpd_banner=Welcome to blah FTP service. 

# You may specify a file of disallowed anonymous e-mail addresses. Apparently 
# useful for combatting certain DoS attacks. 
#deny_email_enable=YES 
# (default follows) 
#banned_email_file=/etc/vsftpd/banned_emails 

# 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 

# When "listen" directive is enabled, vsftpd runs in standalone mode and 
# listens on IPv4 sockets. This directive cannot be used in conjunction 
# with the listen_ipv6 directive. 
# IPv4のみListenします。 
#listen=NO 
listen=YES 

# This directive enables listening on IPv6 sockets. By default, listening 
# on the IPv6 "any" address (::) will accept connections from both IPv6 
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 
# sockets. If you want that (perhaps because you want to listen on specific 
# addresses) then you must run two copies of vsftpd with two configuration 
# files. 
# Make sure, that one of the listen options is commented !! 
#listen_ipv6=YES 
# IPv6はListenしません。 
listen_ipv6=NO 
 
pam_service_name=vsftpd 
userlist_enable=YES 
tcp_wrappers=YES 
 
# SSLを有効化します。 
ssl_enable=YES 
# SSLv2とSSLv3は使用しません。 
#ssl_sslv2=YES 
#ssl_sslv3=YES 
# TLSを使います。 
# TLS 1.0 でのアクセスは許可しません。 
ssl_tlsv1=NO 
# TLS 1.1 でのアクセスは許可します。 
ssl_tlsv1_1=YES 
# TLS 1.2 でのアクセスは許可します。 
ssl_tlsv1_2=YES 
allow_anon_ssl=NO 
# ノンセキュアなFTPは使用させず、SSLを強制します。 
force_local_logins_ssl=YES 
force_local_data_ssl=YES 
# 証明書の場所を指定します。 
rsa_cert_file=/etc/vsftpd/vsftpd.pem 
rsa_private_key_file=/etc/vsftpd/vsftpd.pem 

 

 

■WinSCP のログ

WinSCP のログを確認すると以下の構成になっています。

. 2019-03-21 15:16:26.862 -------------------------------------------------------------------------- 
. 2019-03-21 15:16:26.877 WinSCP バージョン 5.13.8 (ビルド 9278) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional) 
. 2019-03-21 15:16:26.877 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\ 
. 2019-03-21 15:16:26.877 Log level: Normal, Logging passwords 
. 2019-03-21 15:16:26.877 Local account: dell-note\test 
. 2019-03-21 15:16:26.877 Working directory: C:\Program Files\WinSCP 
. 2019-03-21 15:16:26.877 Process ID: 9100 
. 2019-03-21 15:16:26.877 Command-line: "C:\Program Files\WinSCP\WinSCP.exe"  
. 2019-03-21 15:16:26.877 Time zone: Current: GMT+9 (東京 (標準時)), No DST 
. 2019-03-21 15:16:26.877 Login time: 2019年3月21日 15:16:26 
. 2019-03-21 15:16:26.877 -------------------------------------------------------------------------- 
. 2019-03-21 15:16:26.877 Session name: test@xxxxxxx.com (Modified site) 
. 2019-03-21 15:16:26.877 Host name: xxxxxxx.com (Port: 21) 
. 2019-03-21 15:16:26.877 User name: test (Password: xxxxxxxxxxxxxxxxx, Key file: No, Passphrase: No) 
. 2019-03-21 15:16:26.877 Transfer Protocol: FTP 
. 2019-03-21 15:16:26.877 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec 
. 2019-03-21 15:16:26.877 Disable Nagle: No 
. 2019-03-21 15:16:26.877 Proxy: None 
. 2019-03-21 15:16:26.877 Send buffer: 262144 
. 2019-03-21 15:16:26.877 UTF: Auto 
. 2019-03-21 15:16:26.877 FTPS: Explicit TLS/SSL [Client certificate: No] ← Explicit(明示的なモード)になっています。  
. 2019-03-21 15:16:26.877 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto ← パッシブモードになっています。
. 2019-03-21 15:16:26.877 Session reuse: Yes 
. 2019-03-21 15:16:26.877 TLS/SSL versions: TLSv1.0-TLSv1.2 
. 2019-03-21 15:16:26.877 Local directory: C:\Users\test\Desktop\新しいフォルダー, Remote directory: /home/test, Update: Yes, Cache: Yes 
. 2019-03-21 15:16:26.877 Cache directory changes: Yes, Permanent: Yes 
. 2019-03-21 15:16:26.877 Recycle bin: Delete to: No, Overwritten to: No, Bin path:  
. 2019-03-21 15:16:26.877 Timezone offset: 0h 0m 
. 2019-03-21 15:16:26.877 -------------------------------------------------------------------------- 
. 2019-03-21 15:16:26.893 xxxxxxx.com に接続中... 
. 2019-03-21 15:16:27.022 xxxxxxx.com に接続しました。SSL 接続を準備しています... 
< 2019-03-21 15:16:27.032 220 (vsFTPd 3.0.2) 
> 2019-03-21 15:16:27.032 AUTH TLS 
< 2019-03-21 15:16:27.039 234 Proceed with negotiation. 
. 2019-03-21 15:16:27.717 サーバーはクライアント証明での認証を要求しています。 
. 2019-03-21 15:16:27.780 Verifying certificate for "Test Ltd" with fingerprint 5b:30:56:83:a1:06:19:33:0b:43:35:e5:68:cf:09:ee:31:e3:4b:02 and 18 failures 
. 2019-03-21 15:16:27.780 Certificate common name "xxxxxxx.com" matches hostname 
. 2019-03-21 15:16:27.780 Certificate for "Test Ltd" matches cached fingerprint and failures 
. 2019-03-21 15:16:27.780 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-21 15:16:27.842 SSL 接続が確立されました。ウェルカム メッセージを待っています... 
> 2019-03-21 15:16:27.858 USER test 
< 2019-03-21 15:16:27.858 331 Please specify the password. 
> 2019-03-21 15:16:27.858 PASS xxxxxxxxxxxxxxxxxxxxx 
< 2019-03-21 15:16:27.858 230 Login successful. 
> 2019-03-21 15:16:27.858 SYST 
< 2019-03-21 15:16:27.873 215 UNIX Type: L8 
> 2019-03-21 15:16:27.873 FEAT 
< 2019-03-21 15:16:27.889 211-Features: 
< 2019-03-21 15:16:27.889  AUTH TLS 
< 2019-03-21 15:16:27.889  EPRT 
< 2019-03-21 15:16:27.889  EPSV 
< 2019-03-21 15:16:27.889  MDTM 
< 2019-03-21 15:16:27.889  PASV 
< 2019-03-21 15:16:27.889  PBSZ 
< 2019-03-21 15:16:27.889  PROT 
< 2019-03-21 15:16:27.889  REST STREAM 
< 2019-03-21 15:16:27.889  SIZE 
< 2019-03-21 15:16:27.889  TVFS 
< 2019-03-21 15:16:27.889  UTF8 
< 2019-03-21 15:16:27.889 211 End 
> 2019-03-21 15:16:27.889 OPTS UTF8 ON 
< 2019-03-21 15:16:27.905 200 Always in UTF8 mode. 
> 2019-03-21 15:16:27.905 PBSZ 0 
< 2019-03-21 15:16:27.905 200 PBSZ set to 0. 
> 2019-03-21 15:16:27.905 PROT P 
< 2019-03-21 15:16:27.905 200 PROT now Private. 
. 2019-03-21 15:16:27.920 接続しました 
. 2019-03-21 15:16:27.920 --------------------------------------------------------------------------

 

 

■明示的に Implicit モードにする場合

明示的に Implicit モードにする場合、「/etc/vsftpd/vsftpd.conf」ファイルに以下の設定を入れます。

implicit_ssl=YES

 

「YES」で Implicit モードになります。

デフォルトではこの設定は入っていないので、自動的に Explicit モードになります。

明示的に Explicit モードにしたい場合は、「implicit_ssl=NO」の設定を入れます。

 

明示的にパッシブモードにする場合

vsftpd.conf では、特に指定しなければデフォルトでパッシブモードになります。

pasv_enable=YES

パッシブモードを許可したくない場合(アクティブモードにしたい場合)は、「pasv_enable=NO」を設定します。

明示的にパッシブモードに設定したい場合は上記のように「pasv_enable=YES」を設定します。

 

 

パッシブモードの場合で明示的にポート範囲を設定したい場合

パッシブモードの場合、あらかじめサーバーが指定するポート番号を設定(指定)することができます。

パッシブモードの場合は、サーバー側の 1024 番以上のエフェメラルポートに対してパケットが送られてきます。

サーバー側で Firewall を設定していると、データ転送は失敗します。

データ転送用のポート範囲を指定するには、「/etc/vsftpd/vsftpd.conf」ファイルに「pasv_max_port」「pasv_min_port」を設定します。

以下は例として、パッシブモードで利用するエフェメラルポートを明示的に「60010」~「60020」に設定しています。

pasv_min_port=60010

pasv_max_port=60020

 

特に何も設定していない場合は、デフォルトの値になります。場合は、設定されていないので、以下のように設定されているので、どのポートにアクセスされるか分かりません。

 

パッシブモードでファイアウォールを絞った場合

動作検証のため、パッシブモードでファイアウォール(Amazon EC2 のセキュリティグループ)で以下のように絞った場合です。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

WinSCP でログインしようとすると、下図の状態で止まります。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

WinSCP のログは以下のようになっています。

. 2019-03-21 21:08:09.930 -------------------------------------------------------------------------- 
. 2019-03-21 21:08:09.945 WinSCP バージョン 5.13.8 (ビルド 9278) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional) 
. 2019-03-21 21:08:09.945 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\ 
. 2019-03-21 21:08:09.945 Log level: Normal, Logging passwords 
. 2019-03-21 21:08:09.945 Local account: dell-note\test 
. 2019-03-21 21:08:09.945 Working directory: C:\Program Files\WinSCP 
. 2019-03-21 21:08:09.945 Process ID: 6068 
. 2019-03-21 21:08:09.945 Command-line: "C:\Program Files\WinSCP\WinSCP.exe"  
. 2019-03-21 21:08:09.945 Time zone: Current: GMT+9 (東京 (標準時)), No DST 
. 2019-03-21 21:08:09.945 Login time: 2019年3月21日 21:08:09 
. 2019-03-21 21:08:09.945 -------------------------------------------------------------------------- 
. 2019-03-21 21:08:09.945 Session name: test@xxxxxxxxxx.com (Site) 
. 2019-03-21 21:08:09.945 Host name: xxxxxxxxxx.com (Port: 21) 
. 2019-03-21 21:08:09.945 User name: test (Password: xxxxxxxxxxxxxxxx, Key file: No, Passphrase: No) 
. 2019-03-21 21:08:09.945 Transfer Protocol: FTP 
. 2019-03-21 21:08:09.945 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec 
. 2019-03-21 21:08:09.945 Disable Nagle: No 
. 2019-03-21 21:08:09.945 Proxy: None 
. 2019-03-21 21:08:09.945 Send buffer: 262144 
. 2019-03-21 21:08:09.945 UTF: Auto 
. 2019-03-21 21:08:09.945 FTPS: Explicit TLS/SSL [Client certificate: No] 
. 2019-03-21 21:08:09.945 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto 
. 2019-03-21 21:08:09.945 Session reuse: Yes 
. 2019-03-21 21:08:09.945 TLS/SSL versions: TLSv1.0-TLSv1.2 
. 2019-03-21 21:08:09.945 Local directory: C:\Users\xxxxxxxxx\Desktop\新しいフォルダー, Remote directory: /home/test, Update: Yes, Cache: Yes 
. 2019-03-21 21:08:09.945 Cache directory changes: Yes, Permanent: Yes 
. 2019-03-21 21:08:09.945 Recycle bin: Delete to: No, Overwritten to: No, Bin path:  
. 2019-03-21 21:08:09.945 Timezone offset: 0h 0m 
. 2019-03-21 21:08:09.945 -------------------------------------------------------------------------- 
. 2019-03-21 21:08:10.024 xxxxxxxxxx.com に接続中... 
. 2019-03-21 21:08:10.181 xxxxxxxxxx.com に接続しました。SSL 接続を準備しています... 
< 2019-03-21 21:08:10.244 220 (vsFTPd 3.0.2) 
> 2019-03-21 21:08:10.244 AUTH TLS 
< 2019-03-21 21:08:10.275 234 Proceed with negotiation. 
. 2019-03-21 21:08:11.551 サーバーはクライアント証明での認証を要求しています。 
. 2019-03-21 21:08:11.801 Verifying certificate for "Test Ltd" with fingerprint 5b:30:56:83:a1:06:19:33:0b:43:35:e5:68:cf:09:ee:31:e3:4b:02 and 18 failures 
. 2019-03-21 21:08:11.801 Certificate common name "xxxxxxxxxx.com" matches hostname 
. 2019-03-21 21:08:11.801 Certificate for "Test Ltd" matches cached fingerprint and failures 
. 2019-03-21 21:08:11.801 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-21 21:08:11.863 SSL 接続が確立されました。ウェルカム メッセージを待っています... 
> 2019-03-21 21:08:11.863 USER test 
< 2019-03-21 21:08:11.863 331 Please specify the password. 
> 2019-03-21 21:08:11.863 PASS xxxxxxxxxxxxxxxx 
< 2019-03-21 21:08:11.925 230 Login successful. 
> 2019-03-21 21:08:11.925 SYST 
< 2019-03-21 21:08:11.941 215 UNIX Type: L8 
> 2019-03-21 21:08:11.941 FEAT 
< 2019-03-21 21:08:11.985 211-Features: 
< 2019-03-21 21:08:11.986  AUTH TLS 

 

 

 

パッシブモードでエフェメラルポートを指定した場合

以下のように「/etc/vsftpd/vsftpd.conf」ファイルを編集します。

# パッシブモードの設定を明示的に追加
pasv_address=54.xxx.xxx.xxx ← Amazon EC2 インスタンスに割り当てた EIP(Elastic IP)を設定します。
pasv_enable=YES ← パッシブモードにすることを明示的に設定します。

 

# パッシブモードで使用するポート番号(エフェメラルポート番号)を設定します。
pasv_min_port=60010
pasv_max_port=60020

 

 

vsftpd を再起動します。

[root@redhat7 ~]# systemctl restart vsftpd.service 
[root@redhat7 ~]# systemctl status vsftpd.service 
 vsftpd.service - Vsftpd ftp daemon 
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) 
   Active: active (running) since Thu 2019-03-21 13:40:28 UTC; 2s ago 
  Process: 6569 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) 
 Main PID: 6570 (vsftpd) 
   CGroup: /system.slice/vsftpd.service 
           mq6570 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
 
Mar 21 13:40:28 redhat7 systemd[1]: Stopped Vsftpd ftp daemon. 
Mar 21 13:40:28 redhat7 systemd[1]: Starting Vsftpd ftp daemon... 
Mar 21 13:40:28 redhat7 systemd[1]: Started Vsftpd ftp daemon. 
[root@redhat7 ~]#

 

 

セキュリティグループの設定も以下のようにポート番号の範囲を指定して許可します。

 

 

WinSCP で FTPS でサーバーにアクセスできることを確認します。

 

 

ログを確認します。

. 2019-03-21 23:57:08.328 -------------------------------------------------------------------------- 
. 2019-03-21 23:57:08.328 WinSCP バージョン 5.13.8 (ビルド 9278) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional) 
. 2019-03-21 23:57:08.329 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\ 
. 2019-03-21 23:57:08.329 Log level: Normal, Logging passwords 
. 2019-03-21 23:57:08.329 Local account: dell-note\test 
. 2019-03-21 23:57:08.329 Working directory: C:\Program Files\WinSCP 
. 2019-03-21 23:57:08.329 Process ID: 3244 
. 2019-03-21 23:57:08.329 Command-line: "C:\Program Files\WinSCP\WinSCP.exe"  
. 2019-03-21 23:57:08.329 Time zone: Current: GMT+9 (東京 (標準時)), No DST 
. 2019-03-21 23:57:08.329 Login time: 2019年3月21日 23:57:08 
. 2019-03-21 23:57:08.330 -------------------------------------------------------------------------- 
. 2019-03-21 23:57:08.330 Session name: test@xxxxxxxxx.com (Site) 
. 2019-03-21 23:57:08.330 Host name: xxxxxxxxx.com (Port: 21) 
. 2019-03-21 23:57:08.330 User name: test (Password: xxxxxxxxxx, Key file: No, Passphrase: No) 
. 2019-03-21 23:57:08.330 Transfer Protocol: FTP 
. 2019-03-21 23:57:08.330 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec 
. 2019-03-21 23:57:08.330 Disable Nagle: No 
. 2019-03-21 23:57:08.330 Proxy: None 
. 2019-03-21 23:57:08.330 Send buffer: 262144 
. 2019-03-21 23:57:08.330 UTF: Auto 
. 2019-03-21 23:57:08.330 FTPS: Explicit TLS/SSL [Client certificate: No] ← Explicit モードで接続します。 
. 2019-03-21 23:57:08.330 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto ← パッシブモードで接続します。
. 2019-03-21 23:57:08.330 Session reuse: Yes 
. 2019-03-21 23:57:08.331 TLS/SSL versions: TLSv1.0-TLSv1.2 
. 2019-03-21 23:57:08.331 Local directory: C:\Users\xxxx\Desktop\新しいフォルダー, Remote directory: /home/test, Update: Yes, Cache: Yes 
. 2019-03-21 23:57:08.331 Cache directory changes: Yes, Permanent: Yes 
. 2019-03-21 23:57:08.331 Recycle bin: Delete to: No, Overwritten to: No, Bin path:  
. 2019-03-21 23:57:08.331 Timezone offset: 0h 0m 
. 2019-03-21 23:57:08.331 -------------------------------------------------------------------------- 
. 2019-03-21 23:57:08.386 xxxxxxxxx.com に接続中... 
. 2019-03-21 23:57:08.438 xxxxxxxxx.com に接続しました。SSL 接続を準備しています... 
< 2019-03-21 23:57:08.474 220 (vsFTPd 3.0.2) 
> 2019-03-21 23:57:08.474 AUTH TLS 
< 2019-03-21 23:57:08.511 234 Proceed with negotiation. 
. 2019-03-21 23:57:09.635 サーバーはクライアント証明での認証を要求しています。 
. 2019-03-21 23:57:09.787 Verifying certificate for "Test Ltd" with fingerprint 5b:30:56:83:a1:06:19:33:0b:43:35:e5:68:cf:09:ee:31:e3:4b:02 and 18 failures 
. 2019-03-21 23:57:09.787 Certificate common name "xxxxxxxxx.com" matches hostname 
. 2019-03-21 23:57:09.788 Certificate for "Test Ltd" matches cached fingerprint and failures 
. 2019-03-21 23:57:09.788 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-21 23:57:09.835 SSL 接続が確立されました。ウェルカム メッセージを待っています... 
> 2019-03-21 23:57:09.836 USER test 
< 2019-03-21 23:57:09.837 331 Please specify the password. 
> 2019-03-21 23:57:09.837 PASS xxxxxxxxxxxxxxx 
< 2019-03-21 23:57:09.938 230 Login successful. 
> 2019-03-21 23:57:09.938 SYST 
< 2019-03-21 23:57:09.969 215 UNIX Type: L8 
> 2019-03-21 23:57:09.969 FEAT 
< 2019-03-21 23:57:10.003 211-Features: 
< 2019-03-21 23:57:10.005  AUTH TLS 
< 2019-03-21 23:57:10.005  EPRT 
< 2019-03-21 23:57:10.005  EPSV 
< 2019-03-21 23:57:10.005  MDTM 
< 2019-03-21 23:57:10.005  PASV 
< 2019-03-21 23:57:10.005  PBSZ 
< 2019-03-21 23:57:10.005  PROT 
< 2019-03-21 23:57:10.005  REST STREAM 
< 2019-03-21 23:57:10.005  SIZE 
< 2019-03-21 23:57:10.038  TVFS 
< 2019-03-21 23:57:10.039  UTF8 
< 2019-03-21 23:57:10.039 211 End 
> 2019-03-21 23:57:10.039 OPTS UTF8 ON 
< 2019-03-21 23:57:10.076 200 Always in UTF8 mode. 
> 2019-03-21 23:57:10.076 PBSZ 0 
< 2019-03-21 23:57:10.120 200 PBSZ set to 0. 
> 2019-03-21 23:57:10.120 PROT P 
< 2019-03-21 23:57:10.412 200 PROT now Private. 
. 2019-03-21 23:57:10.445 接続しました 
. 2019-03-21 23:57:10.445 -------------------------------------------------------------------------- 
. 2019-03-21 23:57:10.445 Using FTP protocol. 
. 2019-03-21 23:57:10.446 Doing startup conversation with host. 
> 2019-03-21 23:57:10.467 PWD 
< 2019-03-21 23:57:10.506 257 "/home/test" 
. 2019-03-21 23:57:10.506 Changing directory to "/home/test". 
> 2019-03-21 23:57:10.506 CWD /home/test 
< 2019-03-21 23:57:10.543 250 Directory successfully changed. 
. 2019-03-21 23:57:10.543 Getting current directory name. 
> 2019-03-21 23:57:10.543 PWD 
< 2019-03-21 23:57:10.583 257 "/home/test" 
. 2019-03-21 23:57:10.631 ディレクトリ一覧を取得中... 
> 2019-03-21 23:57:10.632 TYPE A 
< 2019-03-21 23:57:10.674 200 Switching to ASCII mode. 
> 2019-03-21 23:57:10.674 PASV 
< 2019-03-21 23:57:10.709 227 Entering Passive Mode (xxx,xxx,xxx,xxx,234,109). 
> 2019-03-21 23:57:10.709 LIST -a 
. 2019-03-21 23:57:10.709 54.xxx.xxx.xxx:60013 に接続中... ← vsftpd.conf ファイルで指定したポート番号にアクセスをしています。
< 2019-03-21 23:57:10.774 150 Here comes the directory listing. 
. 2019-03-21 23:57:10.776 Session ID reused 
. 2019-03-21 23:57:10.776 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-21 23:57:10.797 TLS 接続が確立されました。 
. 2019-03-21 23:57:11.042 drwx------    2 1002     1002          150 Mar 21 14:55 . 
. 2019-03-21 23:57:11.042 drwxr-xr-x    5 0        0              48 Mar 15 13:42 .. 
. 2019-03-21 23:57:11.042 -rw-------    1 1002     1002           16 Mar 16 06:29 .bash_history 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002           18 May 22  2018 .bash_logout 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002          193 May 22  2018 .bash_profile 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002          231 May 22  2018 .bashrc 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002          334 Sep 12  2018 .emacs 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002         1165 Oct 18 13:57 test.txt 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002         1165 Oct 18 13:57 testaaaa.txt 
. 2019-03-21 23:57:11.042 -rw-r--r--    1 1002     1002         1165 Oct 18 13:57 testq.txt 
< 2019-03-21 23:57:11.107 226 Directory send OK. 
. 2019-03-21 23:57:11.107 ディレクトリ一覧の取得が成功しました 
. 2019-03-21 23:57:11.107 Detecting timezone difference... 
. 2019-03-21 23:57:11.108 ファイル情報を取得しています... 
> 2019-03-21 23:57:11.108 PWD 
< 2019-03-21 23:57:11.146 257 "/home/test" 
> 2019-03-21 23:57:11.146 CWD /home/test/.bash_history 
< 2019-03-21 23:57:11.185 550 Failed to change directory. 
> 2019-03-21 23:57:11.185 TYPE I 
< 2019-03-21 23:57:11.226 200 Switching to Binary mode. 
> 2019-03-21 23:57:11.226 SIZE /home/test/.bash_history 
< 2019-03-21 23:57:11.274 213 16 
> 2019-03-21 23:57:11.274 MDTM /home/test/.bash_history 
< 2019-03-21 23:57:11.325 213 20190316062944 
. 2019-03-21 23:57:11.326 ファイルポインタを設定できません。 
. 2019-03-21 23:57:11.326 Timezone difference of -9 detected using file /home/test/.bash_history (Listing: 2019-03-15T21:29:00.000Z, UTC: 2019-03-16T06:29:00.000Z) 

 

 

 

 

WinSCP を使用しての動作検証

WinSCP で動作検証を行います。

 

WinSCP を起動して「新しいサイト」をクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

以下のように設定します。

「保存」ボタンをクリックして「ログイン」ボタンをクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

 

今回の証明書は正式な証明書ではなく、自己署名証明書なので下図のような警告画面が表示されます。

「はい」をクリックします。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

下図のようにファイルをアップロード&ダウンロードできることを確認します。

【SFTP】【CentOS7】【RedHat7】SFTP サーバの構築と設定をしてクライアントPCからファイルを転送する手順

 

 

 

 

SSL/TLS で通信しているか確認する

実際に SSL/TLS で通信ができているのかパケットキャプチャして確認します。

 

以前作成した tcpdump の使い方の記事です。

 

tcpdump のインストールと使い方 パケット解析をする

 

ホストとプロトコルを絞って tcpdump コマンドを実行します。

[root@redhat7 ~]# tcpdump src host xx.xx.xx.253 and -nn not port 22 and not arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
08:00:19.569281 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [S], seq 3634727182, win 8192, options [mss 1414,nop,wscale 2,nop,nop,sackOK], length 0
08:00:19.579009 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 2500216600, win 16614, length 0
08:00:19.588175 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 0:10, ack 21, win 16609, length 10: FTP: AUTH TLS ← AUTH TLS のログが確認できます。
08:00:19.798379 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 52, win 16601, length 0
08:00:19.805271 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 52, win 16601, options [nop,nop,sack 1 {21:52}], length 0
08:00:20.707348 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 10:527, ack 52, win 16601, length 517: FTP
08:00:20.843007 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 527:753, ack 1311, win 16287, length 226: FTP
08:00:20.853343 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 753:806, ack 1561, win 16614, length 53: FTP
08:00:20.866464 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 806:875, ack 1646, win 16593, length 69: FTP
08:00:20.931795 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 875:928, ack 1715, win 16576, length 53: FTP
08:00:20.941230 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 928:981, ack 1784, win 16558, length 53: FTP
08:00:20.952640 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 1906, win 16528, length 0
08:00:20.953182 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 2012, win 16501, length 0
08:00:20.956709 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 2118, win 16475, length 0
08:00:20.961082 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 2224, win 16448, length 0
08:00:20.961090 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 2346, win 16418, length 0
08:00:20.962646 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 981:1050, ack 2505, win 16378, length 69: FTP
08:00:20.975066 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1050:1103, ack 2574, win 16361, length 53: FTP
08:00:20.988180 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1103:1156, ack 2643, win 16344, length 53: FTP
08:00:21.034905 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1156:1209, ack 2712, win 16326, length 53: FTP
08:00:21.049205 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1209:1278, ack 2781, win 16309, length 69: FTP
08:00:21.063520 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1278:1331, ack 2866, win 16288, length 53: FTP
08:00:21.201350 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1331:1384, ack 2935, win 16271, length 53: FTP
08:00:21.224777 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1384:1437, ack 3020, win 16614, length 53: FTP
08:00:21.246297 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1437:1490, ack 3121, win 16589, length 53: FTP
08:00:21.246304 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [S], seq 1567955025, win 8192, options [mss 1414,nop,wscale 2,nop,nop,sackOK], length 0
08:00:21.266899 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [.], ack 539144898, win 16614, length 0
08:00:21.266930 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [P.], seq 0:517, ack 1, win 16614, length 517
08:00:21.290959 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [P.], seq 517:592, ack 167, win 16573, length 75
08:00:21.500065 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 3206, win 16568, length 0
08:00:21.508632 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 3206, win 16568, options [nop,nop,sack 1 {3121:3206}], length 0
08:00:21.515532 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [.], ack 956, win 16375, length 0
08:00:21.524179 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [P.], seq 592:645, ack 1009, win 16362, length 53
08:00:21.524726 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [F.], seq 645, ack 1009, win 16362, length 0
08:00:21.534435 IP xx.xx.xx.253.50560 > 172.31.xx.xx.31360: Flags [.], ack 1010, win 16362, length 0
08:00:21.545577 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1490:1543, ack 3275, win 16550, length 53: FTP
08:00:21.554200 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1543:1628, ack 3344, win 16533, length 85: FTP
08:00:21.562719 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1628:1681, ack 3429, win 16512, length 53: FTP
08:00:21.570821 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1681:1766, ack 3514, win 16491, length 85: FTP
08:00:21.579383 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1766:1851, ack 3567, win 16477, length 85: FTP
08:00:21.796575 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 3636, win 16460, length 0
08:00:43.730039 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1851:1904, ack 3636, win 16460, length 53: FTP
08:00:43.738006 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1904:1957, ack 3721, win 16439, length 53: FTP
08:00:43.746605 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [S], seq 2072618846, win 8192, options [mss 1414,nop,wscale 2,nop,nop,sackOK], length 0
08:00:43.747184 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 1957:2026, ack 3822, win 16414, length 69: FTP
08:00:43.754061 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [.], ack 2749021531, win 16560, length 0
08:00:43.762975 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [P.], seq 0:517, ack 1, win 16560, length 517
08:00:43.772102 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [P.], seq 517:592, ack 167, win 16518, length 75
08:00:43.978326 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 3891, win 16396, length 0
08:00:44.125450 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [.], seq 592:2006, ack 167, win 16518, length 1414
08:00:44.135251 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [.], seq 3472:4886, ack 167, win 16518, length 1414
08:00:44.143216 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [.], seq 2006:3420, ack 167, win 16518, length 1414
08:00:44.144377 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [FP.], seq 3420:5706, ack 167, win 16518, length 2286
08:00:44.152787 IP xx.xx.xx.253.50561 > 172.31.xx.xx.30015: Flags [R.], seq 5707, ack 220, win 0, length 0
08:00:44.166770 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 2026:2111, ack 3960, win 16379, length 85: FTP
08:00:44.239569 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 2111:2164, ack 4045, win 16358, length 53: FTP
08:00:44.248769 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 2164:2217, ack 4130, win 16337, length 53: FTP
08:00:44.258116 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [S], seq 3117023890, win 8192, options [mss 1414,nop,wscale 2,nop,nop,sackOK], length 0
08:00:44.258165 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [P.], seq 2217:2270, ack 4231, win 16311, length 53: FTP
08:00:44.265002 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [.], ack 1418365155, win 16614, length 0
08:00:44.265578 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [P.], seq 0:517, ack 1, win 16614, length 517
08:00:44.273640 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [P.], seq 517:592, ack 167, win 16573, length 75
08:00:44.479282 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 4316, win 16290, length 0
08:00:44.486733 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [.], ack 1073, win 16346, length 0
08:00:44.487941 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [P.], seq 592:645, ack 1073, win 16346, length 53
08:00:44.487952 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [F.], seq 645, ack 1073, win 16346, length 0
08:00:44.496538 IP xx.xx.xx.253.50562 > 172.31.xx.xx.5479: Flags [.], ack 1074, win 16346, length 0
08:00:44.709584 IP xx.xx.xx.253.50559 > 172.31.xx.xx.21: Flags [.], ack 4385, win 16273, length 0
^C
68 packets captured
68 packets received by filter
0 packets dropped by kernel
[root@redhat7 ~]#

 

 

 

WinSCP のログを確認します。

TLSv2 でアクセスしていることが確認できます。

. 2019-03-16 17:09:46.751 -------------------------------------------------------------------------- 
. 2019-03-16 17:09:46.751 WinSCP バージョン 5.13.8 (ビルド 9278) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional) 
. 2019-03-16 17:09:46.751 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\ 
. 2019-03-16 17:09:46.751 Log level: Normal, Logging passwords 
. 2019-03-16 17:09:46.751 Local account: xxx\xxxxxxxxxx 
. 2019-03-16 17:09:46.751 Working directory: C:\Program Files\WinSCP 
. 2019-03-16 17:09:46.751 Process ID: 2720 
. 2019-03-16 17:09:46.751 Command-line: "C:\Program Files\WinSCP\WinSCP.exe"  
. 2019-03-16 17:09:46.751 Time zone: Current: GMT+9 (東京 (標準時)), No DST 
. 2019-03-16 17:09:46.751 Login time: 2019年3月16日 17:09:46 
. 2019-03-16 17:09:46.751 -------------------------------------------------------------------------- 
. 2019-03-16 17:09:46.751 Session name: test@xxxxxxxxx.com (Site) 
. 2019-03-16 17:09:46.751 Host name: xxxxxxxxx.com (Port: 21) 
. 2019-03-16 17:09:46.751 User name: test (Password: xxxxxxxxx, Key file: No, Passphrase: No) 
. 2019-03-16 17:09:46.751 Transfer Protocol: FTP 
. 2019-03-16 17:09:46.751 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec 
. 2019-03-16 17:09:46.751 Disable Nagle: No 
. 2019-03-16 17:09:46.751 Proxy: None 
. 2019-03-16 17:09:46.751 Send buffer: 262144 
. 2019-03-16 17:09:46.751 UTF: Auto 
. 2019-03-16 17:09:46.751 FTPS: Explicit TLS/SSL [Client certificate: No] 
. 2019-03-16 17:09:46.751 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto 
. 2019-03-16 17:09:46.751 Session reuse: Yes 
. 2019-03-16 17:09:46.751 TLS/SSL versions: TLSv1.0-TLSv1.2 
. 2019-03-16 17:09:46.751 Local directory: C:\Users\xxxxxxxxxx\Desktop\新しいフォルダー, Remote directory: /home/test, Update: Yes, Cache: Yes 
. 2019-03-16 17:09:46.751 Cache directory changes: Yes, Permanent: Yes 
. 2019-03-16 17:09:46.751 Recycle bin: Delete to: No, Overwritten to: No, Bin path:  
. 2019-03-16 17:09:46.751 Timezone offset: 0h 0m 
. 2019-03-16 17:09:46.751 -------------------------------------------------------------------------- 
. 2019-03-16 17:09:46.798 xxxxxxxxx.com に接続中... 
. 2019-03-16 17:09:46.813 xxxxxxxxx.com に接続しました。SSL 接続を準備しています... 
< 2019-03-16 17:09:46.813 220 (vsFTPd 3.0.2) 
> 2019-03-16 17:09:46.813 AUTH TLS 
< 2019-03-16 17:09:46.813 234 Proceed with negotiation. 
. 2019-03-16 17:09:47.948 サーバーはクライアント証明での認証を要求しています。 
. 2019-03-16 17:09:48.073 Verifying certificate for "Test Ltd" with fingerprint 5b:30:56:83:a1:06:19:33:0b:43:35:e5:68:cf:09:ee:31:e3:4b:02 and 18 failures 
. 2019-03-16 17:09:48.073 Certificate common name "xxxxxxxxx.com" matches hostname 
. 2019-03-16 17:09:48.073 Certificate for "Test Ltd" matches cached fingerprint and failures 
. 2019-03-16 17:09:48.073 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-16 17:09:48.089 SSL 接続が確立されました。ウェルカム メッセージを待っています... 
> 2019-03-16 17:09:48.089 USER test 
< 2019-03-16 17:09:48.089 331 Please specify the password. 
> 2019-03-16 17:09:48.089 PASS xxxxxxxxxxxxxxxxx 
< 2019-03-16 17:09:48.151 230 Login successful. 
> 2019-03-16 17:09:48.151 SYST 
< 2019-03-16 17:09:48.151 215 UNIX Type: L8 
> 2019-03-16 17:09:48.151 FEAT 
< 2019-03-16 17:09:48.167 211-Features: 
< 2019-03-16 17:09:48.167  AUTH TLS 
< 2019-03-16 17:09:48.167  EPRT 
< 2019-03-16 17:09:48.167  EPSV 
< 2019-03-16 17:09:48.167  MDTM 
< 2019-03-16 17:09:48.167  PASV 
< 2019-03-16 17:09:48.167  PBSZ 
< 2019-03-16 17:09:48.167  PROT 
< 2019-03-16 17:09:48.167  REST STREAM 
< 2019-03-16 17:09:48.167  SIZE 
< 2019-03-16 17:09:48.167  TVFS 
< 2019-03-16 17:09:48.167  UTF8 
< 2019-03-16 17:09:48.167 211 End 
> 2019-03-16 17:09:48.167 OPTS UTF8 ON 
< 2019-03-16 17:09:48.213 200 Always in UTF8 mode. 
> 2019-03-16 17:09:48.213 PBSZ 0 
< 2019-03-16 17:09:48.229 200 PBSZ set to 0. 
> 2019-03-16 17:09:48.229 PROT P 
< 2019-03-16 17:09:48.245 200 PROT now Private. 
. 2019-03-16 17:09:48.276 接続しました 
. 2019-03-16 17:09:48.276 -------------------------------------------------------------------------- 
. 2019-03-16 17:09:48.276 Using FTP protocol. 
. 2019-03-16 17:09:48.276 Doing startup conversation with host. 
> 2019-03-16 17:09:48.291 PWD 
< 2019-03-16 17:09:48.307 257 "/home/test" 
. 2019-03-16 17:09:48.307 Changing directory to "/home/test". 
> 2019-03-16 17:09:48.307 CWD /home/test 
< 2019-03-16 17:09:48.307 250 Directory successfully changed. 
. 2019-03-16 17:09:48.307 Getting current directory name. 
> 2019-03-16 17:09:48.307 PWD 
< 2019-03-16 17:09:48.323 257 "/home/test" 
. 2019-03-16 17:09:48.369 ディレクトリ一覧を取得中... 
> 2019-03-16 17:09:48.369 TYPE A 
< 2019-03-16 17:09:48.369 200 Switching to ASCII mode. 
> 2019-03-16 17:09:48.369 PASV 
< 2019-03-16 17:09:48.385 227 Entering Passive Mode (172,xx,xx,xx,68,166). 
. 2019-03-16 17:09:48.385 Server sent passive reply with unroutable address 172.31.xx.xx, using host address instead. 
> 2019-03-16 17:09:48.385 LIST -a 
. 2019-03-16 17:09:48.385 54.xx.xx.xx:17574 に接続中... 
< 2019-03-16 17:09:48.401 150 Here comes the directory listing. 
. 2019-03-16 17:09:48.401 Session ID reused 
. 2019-03-16 17:09:48.401 Using TLSv1.2, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 1024 bit RSA, DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1 
. 2019-03-16 17:09:48.416 TLS 接続が確立されました。 
. 2019-03-16 17:09:48.615 drwx------    2 1002     1002          190 Mar 16 08:00 . 
. 2019-03-16 17:09:48.615 -rw-r--r--    1 1002     1002         1165 Oct 18 13:57 test.txt 
< 2019-03-16 17:09:48.630 226 Directory send OK. 
. 2019-03-16 17:09:48.630 ディレクトリ一覧の取得が成功しました 
. 2019-03-16 17:10:03.140 サーバから切断されました。 

 

 

 

トラブルシューティング

鍵がうまく作成できていないと以下のように「500 OOPS: SSL: cannot load RSA certificate 」のメッセージが出力されます。

[root@redhat7 ~]# systemctl status vsftpd.service -l 
● vsftpd.service - Vsftpd ftp daemon 
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled) 
   Active: failed (Result: exit-code) since Tue 2019-03-12 13:03:53 UTC; 18s ago 
  Process: 6384 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=2) 
 
Mar 12 13:03:53 redhat7 systemd[1]: Starting Vsftpd ftp daemon... 
Mar 12 13:03:53 redhat7 vsftpd[6384]: 500 OOPS: SSL: cannot load RSA certificate 
Mar 12 13:03:53 redhat7 systemd[1]: vsftpd.service: control process exited, code=exited status=2 
Mar 12 13:03:53 redhat7 systemd[1]: Failed to start Vsftpd ftp daemon. 
Mar 12 13:03:53 redhat7 systemd[1]: Unit vsftpd.service entered failed state. 
Mar 12 13:03:53 redhat7 systemd[1]: vsftpd.service failed. 
[root@redhat7 ~]#

 

 

パスフレーズが付いている場合や、証明書がうまく作成できていない場合はエラーになります。

-----BEGIN CERTIFICATE-----
MIIDjjCCAnYCCQCuIjDKAEOVKDANBgkqhkiG9w0BAQsFADCBiDELMAkGA1UEBhMC
SlAxDjAMBgNVBAgMBVRPS1lPMQ4wDAYDVQQHDAVUT0tZTzEZMBcGA1UECgwQVGVz
dCBDb21wYW55IEx0ZDELMAkGA1UECwwCSVQxEzARBgNVBAMMCmJveC1jbS5jb20x
HDAaBgkqhkiG9w0BCQEWDXRlc3RAdGVzdC5jb20wHhcNMTkwMzEwMTQxMTM5WhcN
MTkwNDA5MTQxMTM5WjCBiDELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRPS1lPMQ4w
DAYDVQQHDAVUT0tZTzEZMBcGA1UECgwQVGVzdCBDb21wYW55IEx0ZDELMAkGA1UE
CwwCSVQxEzARBgNVBAMMCmJveC1jbS5jb20xHDAaBgkqhkiG9w0BCQEWDXRlc3RA
dGVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD3o5BG3WyN
k5E3m1mP/e98nnNyagYNU8GHdoSPFZ9i+wFwecZi05/wvdhnElFIhvd/BMq7N2z+
QWVTUTnB1HLTTtFF8hS58JVGiRNJmk3jwkzisONRxn+Ii1KXX+hnVZ9/NAgsk7Vr
OQ62jRLOSd5Nl/THEjRLHSwstTOWDsLi3Nvb4RWhSfU4WdCaFuPN83NlsEAEx4xU
wbGIGVw0SSXKWE3IdySoipiqJde+W1q+P8CNOx6nlDA8rJvHzxqS0tqRRMVDkcJB
qR8l9VBSlQLvG2lHDlxRx9csrKC5/EX8A9pqc0QsSJr7QFQR2MjtDDnOwZzVqXnr
mEiV3f8ZD5eZAgMBAAEwDQYJKoZIhvcNAQELBQADggEBALPLtGDitunohLlJIHaQ
s8ioptX4aSiTLfP20B6FxsIglL83yvl28Wjc5eGTYUa6VdM3iRHOwn+wxcqQzET1
0km0calrcHe/lOpheflFzP5gNNX1/2FwMTOoV5fs4V69bmUrmG6ant98Mb/k889t
24cnebc4qx9V+1CwX7Ags/xw7mCDCrqhNhUd+7Dk4EyTpvXICtfoo2y2oBqRIzwL
Humwr5Mz5WFz2jeTVECC+Dt5RvjQ1owzpvEygzegJfwU5YOp2f1iJLHHNf5RSMQi
oaoB5YLBn8UFCE/y+eO9+cZS8c6jjXK/m+ISFazlKBaRDxYPVKvGu1B6hVAh+3tG
jE0=
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
NpMcjJvat1jg0JiNXFIrcXl2ZfZoEAHnHyDZstkm1+nqKJkWpYAfJs5O71jHWI5M
WKE4xIx902/HxS2MteIrBCJ9BYvxNJKUMERlxuv45CMOeDWshFw1NnR+KRKlvFNV
jWD49/CBj+IBt5WlVsJlmagpI6koxFBrNSI2LKUUH7cMyaM+2BGmCA4DeHMpqpM7
broq29W6O2jDqxsYPx2E48f3kxpP+cl4bkFwdUYVkLxmSpixeK0Hv8YPkhDqa+un
k9tGeOZllW38Z/4dwdyqVmb77wwDyN2SvNy8PILTwKhFEoo2yOEDXXsnhVXme9uR
LdjhZqa60FYa3LMmh+6hKB8eIWWJllyT+zG2X4LsGm7c0QkEujSU4gj8EHw65mP2
5+OGeMSvJMBsXGETs27dnioiRDFM3vG4qV3OvcoGXwFrqa0ZWMsbMGsYj1yU/YC9
sUBp8cQ9/R4ArY8Vvr9CZU+9xVmhKajKQUk0TmFoXQfPRb1l+7lb8gnHbUSRDMCw
Zv0Sjtq4HC72I0MhmNNJVx46/g/nwvnW3fMc9juws/6T5uwf2ARXdnvhtgqXr8gK
vwe7P875H1mnxDGtqeV8pgIAGLbvOBNMGMKZPgKvgqbKho841XKQYRyOnoC58Hsf
HPJfNMpAvsguU4XhKRrUdDoH4ew5L1rTJ4E/PaT7LyrlKeEE5Fh/axg7Bh9JhP/u
ieg5AbXHMsjVd8rfXqFeY1jfoEjwXH+TvNTsqChP6I9naNmjIzh5vlHnO61K4j3i
P8469GGEVeJTY7mOJVYnOHhHA2QFdaRdyNhC5TlxCAMv6QndnuOlXYKDM7cdViSZ
eXbgkGlaY3JP/IHQqbLIUDG/ho8LKrZcMWfj5YQtpyLS7bCM7+7T+9kqyjbZB2nY
vgOtyA8fVNNvL+pmDxdTrQ0x0FblORrfbiOUm2KIz4wYyKXTUypapO521tTt5PnW
J+G9JJTQ0qYUOTuy7b2ARLKuFfnLOFwlhE2tqMQ5H3PT/6PFdm6aPQ2R8hphYu+M
n9T2ZR6YPcjxJFPUwFCAtIV+DaESs1KhvdaqIgWkzHbDgsledO/jbTQCZb5MPjZ1
LgsPtwS3hONjBzdS+Zg/LA9qrQ0nJIGPsj1pGpQpvWHWMcfOd6RdJNhhathbiG64
nL7q6LDFmw5SzuNK9IjJHpF3hF+PHGnDY8Hz+Rfyso3a/NvpWbeFz4/6ohYZ8xGj
EZ8PLQnkNj8s8qbNniqiytxim7iXUTREdiIJyvD3WMKb+sTLD8MnnEA84jrDfD89
oNwL4mezyulY90+ArhHiGi6g9pudT74u26NgIfe8BINv+AW6aCkfEv3OI4aifUon
Fk0D3X+ao9fQXh8eP6yVKiJg/WDMaCDeHA7iEb3F77Tivophu2YdpsfKXXMbu0me
VQimlpKKjdRQ8IkXEDfglmSMCcL/ZSumwGxLXrmXLxmVCnrYRvxhLHAeW0Q5Uatg
kAai3LtmNKo+7wg6ce46++SOXzu9Nlwy491oCN2rCnuqJfbqGwx5LN8/KcwGLt9e
cnYStU339q+QRwF0xj9Oc6vuYzhYmDF8LeVf2UiVh+QkYjWhF6pI9OMWwQOhcYT1
-----END RSA PRIVATE KEY-----

 

 

 

Posted by 100%レンタルサーバーを使いこなすサイト管理人

Secured By miniOrange