I can only get to hostB from hostA, and I want to run commands on hostB.
ssh -t $hostA ssh -t $hostB "
echo 'Hello World!'
echo 'Test!'
"
At the moment, this will connect to hostA then hostB and the script will pause. As soon as i type exit (from hostB) I return to hostA, the 2 echo commands are printed and then automatically exits from hostA.
How can I run commands on hostB?
Changing code as using here document and sshpass
can do the trick
ssh -T user@$hostA <<EOA
sshpass -p password ssh -T user@$hostB <<EOB
echo hello
EOB
EOA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With