LoginSignup
0
0

More than 1 year has passed since last update.

さくらインターネットのレンタルサーバにLFTPを使ってFTPSによるミラーリングを行う場合の設定

Last updated at Posted at 2023-02-13

さくらインターネットのレンタルサーバ、スタンダードプランで運用しているサーバに LFTP を用いて、FTPS(SFTPではなく、FTP over SSL)を用いてファイルをアップロードする際のオプションなどについて共有します。

設定

とりあえず、以下の設定でミラーを行うことが可能でした。
サーバ名(FTP_SERVER)、ユーザー名(FTP_USERNAME)、パスワード(FTP_PASSWORD)、送信元のディレクトリ(SRC)、送信先のディレクトリ(DST)は環境変数に設定されています。

lftp <<EOM
set ftp:ssl-auth TLS
set ftp:ssl-force yes
set ftp:use-feat no
open $FTP_SERVER
user $FTP_USERNAME $FTP_PASSWORD
mirror -X .* -X .*/ --reverse --only-newer --verbose $SRC $DST
bye
EOM

オプションのポイント

  • ftp:ssl-auth TLS によりSSL接続の認証方法を設定しています。
  • ftp:ssl-force yes により、SSL接続を強制しています。
  • ftp:use-feat は通常デフォルトの設定値が yes になっています、その場合、LFTPは SSL 接続開始のための AUTH コマンドを実施する前に FEAT コマンドで相手がどんな認証方法をサポートしているか確認するようです。
    しかし、さくらインターネットのサーバは FEAT コマンドに返答しないため、この値を no に設定し、AUTH コマンドを決め打ちで実施します。

補足:実験

LFTP の debug コマンドで動作ログを有効にして ftp:use-feat の影響を見てみます。

LFTPの ftp:use-feat: yes の場合の挙動:

lftp <<EOM
debug 10
set ftp:ssl-auth TLS
set ftp:ssl-force yes
open $FTP_SERVER
user $FTP_USERNAME $FTP_PASSWORD
ls
EOM
---- ホストアドレスを解決しています...
---- IPv6 is not supported or configured
buffer: EOF on FD 4
---- 1 address found: ***.***.128.***
---- dns cache hit
---- attempt number 1 (max_retries=1000)
---- ***.sakura.ne.jp (***.***.128.***) ポート 21 に接続中
<--- 220 ProFTPD Server (SAKURA Internet FTP Server) [::ffff:***.***.128.***]
---> FEAT
`ls' (現在 0 バイト) [FEAT negotiation...]

FTP の FEAT コマンドに対する返答はなく、処理はここで止まります。

ftp:use-feat no の場合の挙動は以下の通り:

lftp <<EOM
debug 10
set ftp:ssl-auth TLS
set ftp:ssl-force yes
set ftp:use-feat no
open $FTP_SERVER
user $FTP_USERNAME $FTP_PASSWORD
ls
EOM
---- ホストアドレスを解決しています...
---- IPv6 is not supported or configured
buffer: EOF on FD 4
---- 1 address found: ***.***.128.***
---- dns cache hit
---- attempt number 1 (max_retries=1000)
---- ***.sakura.ne.jp (***.***.128.***) ポート 21 に接続中
<--- 220 ProFTPD Server (SAKURA Internet FTP Server) [::ffff:***.***.128.***]
---> AUTH TLS
<--- 234 AUTH TLS successful                                 
---> USER ***
Certificate depth: 2; subject: /C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority; issuer: /C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
Certificate depth: 1; subject: /C=JP/ST=Tokyo/L=Chiyoda-ku/O=Gehirn Inc./CN=Gehirn Managed Certification Authority - RSA DV; issuer: /C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
Certificate depth: 0; subject: /CN=*.sakura.ne.jp; issuer: /C=JP/ST=Tokyo/L=Chiyoda-ku/O=Gehirn Inc./CN=Gehirn Managed Certification Authority - RSA DV
Certificate verification: subjectAltName: ‘***.sakura.ne.jp’ matched
<--- 331 Password required for ***                  
---> PASS ***
<--- 230 User *** logged in                      
---> PWD
<--- 257 "/home/***" is the current directory    
---> PBSZ 0
<--- 200 PBSZ 0 successful                               
---> PROT P
<--- 200 Protection set to Private                          
---> PASV
<--- 227 Entering Passive Mode (***,***,128,***,***,173).    
---- データソケットを (***.***.128.***) のポート 56237 に接続中
---- Data connection established                            
0:0 translated to pair 0:0 (0,0)
0 translated to pair 0:0 (0,0)
0:0 translated to pair 0:0 (0,0)
0 translated to pair 0:0 (0,0)
0:0 translated to pair 0:0 (0,0)
0 translated to pair 0:0 (0,0)
---> LIST
<--- 150 Opening ASCII mode data connection for file list   
Certificate verification: subjectAltName: ‘***.sakura.ne.jp’ matched
---- Got EOF on data connection                 
---- データソケットを閉じています

先に進みました。
FEAT をスキップして AUTH TLS と認証方法を決めうちにして実施しているのがわかります。

環境

さくらインターネットのサーバ情報:

  • OSバージョン FreeBSD 13.0-RELEASE-p13 amd64
  • CPU Intel Xeon Processor (Cascadelake)
  • メモリ容量 48GB
  • Webサーバー Apache/2.4.54

LFTPの情報:

LFTP | Version 4.9.2 | Copyright (c) 1996-2020 Alexander V. Lukyanov

参考

これによると、FTPS は Explicit Mode で利用されることを期待されています。すなわち SSL は AUTH コマンドにより開始されます。

0
0
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
0
0