LightFile NextLightFile Next

SFTP

SFTPサーバー上のファイルを最適化

SSH File Transfer Protocolを使用した安全なファイル転送です。

パスワード認証

ユーザー名とパスワードで認証します。シンプルな接続方法ですが、秘密鍵認証の方がより安全です。

コマンドライン:

lightfile-batch sftp \
  --sftp-host sftp.example.com \
  --sftp-user myuser \
  --sftp-password mypassword \
  --sftp-dir /images

YAML設定ファイル:

sftp:
  host: sftp.example.com
  port: 22
  user: myuser
  password: mypassword
  dir: /images

秘密鍵認証(推奨)

SSH秘密鍵を使用した認証です。パスワード認証よりも安全で、サーバー管理で一般的に推奨される方式です。

コマンドライン:

# パスフレーズなしの秘密鍵
lightfile-batch sftp \
  --sftp-host sftp.example.com \
  --sftp-user myuser \
  --sftp-private-key ~/.ssh/id_rsa \
  --sftp-dir /images

# パスフレーズ付き秘密鍵
lightfile-batch sftp \
  --sftp-host sftp.example.com \
  --sftp-user myuser \
  --sftp-private-key ~/.ssh/id_rsa \
  --sftp-passphrase mypassphrase \
  --sftp-dir /images

YAML設定ファイル:

sftp:
  host: sftp.example.com
  port: 22
  user: myuser
  privateKeyPath: ~/.ssh/id_rsa
  privateKeyPassword: mypassphrase  # パスフレーズ付き秘密鍵の場合
  dir: /images