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

Popular posts from this blog

c - CUDA code not processing if block properly -

oracle11g - get root domain from url Oracle sql regex_substr -

xcode - Swift Playground - Files are not readable -