I'm not sure I have the capability to test this right now, but was wondering if someone might advise if it is possible to do something like this:
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
Presumably it's just a case of assembling the required level of script and letting it run? To steal an example from another SoF question:
sshScript='
ls -la
sshScript2=`
ls -la
`
ssh -t ${UserName}@server "${sshScript2}"
ls -la
'
ssh -t ${UserName}@server "${sshScript}"
Where in the case of sudo stuff I just run sudo -s -u user bash -c script
or whatever?
I'm just unsure if this will result in an endless loop, and as the machines I'm connecting to are in a production environment, I can't afford to risk breaking them for the purpose of testing.