現在までに可能な解決策

現在までに可能な解決策

これを賢く行う方法はありますか?

scp user@host:/path/to/file /dev/tty | openssl [options] | less

ファイルを生成したり、パラメータに直接パスワードを入力する必要はありませんか?

問題はどちらもパスワードを要求しますが、開始順序(したがってパスワードを要求する順序)が定義されていないことです。

scp最初に完了してから起動すると問題はありませんが、一時opensslファイルはありません。

現在までに可能な解決策

  • 出力をscp変数に入れて変数を入れますopenssl(小さなファイルでのみ動作し、バイナリデータなどに問題があると思われます)。
  • パスワードをファイル(悪い)
  • キー(より良いですか?)
  • 名前付きパイプの使用


名前付きパイプバージョン1

mkfifo pipe && {
  scp user@host:/path/to/file pipe    # asks for password, then waits
                                      # for read from pipe to finish
                                      # which will only happen after the
                                      # password for openssl was supplied
                                      # => must ^Z and enter the password
                                      #  => `pipe: Interrupted system call'

  openssl [options] -in pipe | less
}


名前付きパイプバージョン2

mkfifo pipe && {
  scp user@host:/path/to/file pipe &  # asks for password (and works when
                                      # password is entered) despite being 
                                      # put in background (what? how?
                                      #  can someone explain?)

  openssl [options] -in pipe | less   # `bad password read'
}


名前付きパイプバージョン3

mkfifo pipe && {
  scp user@host:/path/to/file pipe |  # asks for password first

  openssl [options] -in pipe | less   # asks for password after scp's
                                      # password has been entered
                                      # and everything works fine
}

コマンドを切り替えても役に立ちません。


openssl [options] -in <(scp user@host:/path/to/file /dev/tty) | less動作しません。


誰でもお願いします

  1. 別の解決策を提案し、
  2. 例1に関連して、scpの異常な動作(「システムコールの中断」)について説明します(バグまたはある種の「セキュリティ機能」と仮定します)。

  3. パスワードの入力方法を説明してください。バックグラウンドで開始されたタスクをstdinで読み込む方法は?

  4. (3に関連しています。)stdoutとstderrの両方にリダイレクトされたにもかかわらず、例2のscpがパスワードプロンプトを印刷する理由を説明してください/dev/null


ベストアンサー1

おすすめ記事