1

rsyncクライアント上のデータをサーバー上の復号化された ecryptfs-container と同期するために使用します。

私が達成したいのは、次の自動プロセスです。

  1. サーバー上にkeyctl show目的の調号がすでにある場合は、(3.) に進みます。
  2. ecryptfs-add-passphrase --fnekサーバー上のキーリングにキーを追加するには
  3. mount -i /mnt/path/to/decrypted復号化されたフォルダーがサーバーにマウントされていることを確認する
  4. rsyncクライアントからサーバーへ
  5. オプション: フォルダーのマウントを解除し、調号を削除します (ここでは重要ではありません)。

現在、ステップ1、2、3ではssh -tq ...、コマンドを実行して結果を評価するために使用しています。

私の問題は次のとおりです。ecryptfs には、サーバー上で永続的なユーザー セッションが必要なようです。それ以外の場合、キーは追加され、ユーザーのログアウトのために即座に削除されます (ssh -tq ...コマンドの完了後に終了します)。

ssh -tq 'ecryptfs-add-passphrase --fnek; mount -i /mnt/path/to/decrypted'どうやら期待どおりに動作することを認識しました。その後、キーは再びドロップされますが、マウントは成功します。これは、サーバー上で「動的プロンプト」(ステップ 1) を認識しなければならないことを意味します。これはすでに最適なソリューションですか、それともクライアントでも実現できますか?

4

1 に答える 1

1

今日、あなたが説明していることを正確に理解しようとしているときに、あなたの投稿に何度か出くわしましたが、何の助けも見つかりませんでした. 私は最終的に自分で解決策を見つけることができました。

この解決策は--rsync-path、rsync のオプションを利用することです。マニュアルページからの抜粋は次のとおりです。

    --rsync-path=PROGRAM
          Use this to specify what program is to  be  run  on  the  remote
          machine  to start-up rsync.  Often used when rsync is not in the
          default      remote-shell’s      path       (e.g.       --rsync-
          path=/usr/local/bin/rsync).   Note  that PROGRAM is run with the
          help of a shell, so it can be any program,  script,  or  command
          sequence  you’d  care to run, so long as it does not corrupt the
          standard-in & standard-out that rsync is using to communicate.

          One tricky example is to set a different  default  directory  on
          the  remote  machine  for  use  with the --relative option.  For
          instance:

              rsync -avR --rsync-path="cd /a/b && rsync" hst:c/d /e/

マニュアルの最後の段落に示されている例から、このパラメーターを使用して ecryptfs ディレクトリをマウントするというアイデアが得られました。

コードは次のとおりです。

rsync --rsync-path="(printf \"%s\" \"$passphrase\" | ecryptfs-add-passphrase --fnek && ecryptfs-mount-private) &> /dev/null && rsync" -aKLv local_to_sync remotehost.com:~/Private/
于 2016-09-11T21:24:55.660 に答える