今すぐこれをテストする能力があるかどうかはわかりませんが、次のようにできるか提案できる人がいるかどうか疑問に思います。
Run a shell script
Shell Script SSH's into a machine (Connection requires SSH key only)
Stuff is run on that machine
Script run on that machine SSH's into another machine (Connection requires SSH key and password)
Stuff is run in that machine
Exit from that machine
Stuff is run in that machine
Exit from that machine
More stuff happens for a few hours
おそらく、必要なスクリプトのスクリプトを組み立てて実行させるだけです。他のSoF問題の例を借りるには:
sshScript='
ls -la
sshScript2=`
ls -la
`
ssh -t ${UserName}@server "${sshScript2}"
ls -la
'
ssh -t ${UserName}@server "${sshScript}"
sudoの場合、何を実行する必要がありますかsudo -s -u user bash -c script
?
これは無限ループが発生するかどうかわからず、接続されているコンピュータが生産中であるため、テスト目的でそのコンピュータを損傷する危険性を余裕がありません。
ベストアンサー1
この場合、私は通常heredocを使用してリモートシェルにスクリプトを提供します。ただし、スクリプトが標準入力のユーザー入力を要求する場合は使用できません。
ssh ${UserName}@server <<EOF1
ls -la
ssh ${UserName}@server <<EOF2
ls -la
EOF2
ls -la
EOF1