bash - Nested ssh run commands on 2nd server -
i can hostb hosta, , want run commands on hostb.
ssh -t $hosta ssh -t $hostb " echo 'hello world!' echo 'test!' "
at moment, connect hosta hostb , script pause. type exit (from hostb) return hosta, 2 echo commands printed , automatically exits hosta.
how can run commands on hostb?
changing code using here document , sshpass
can trick
ssh -t user@$hosta <<eoa sshpass -p password ssh -t user@$hostb <<eob echo hello eob eoa
Comments
Post a Comment