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++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -