0

Can't find the solution. I need in the script - ssh to a server then change to root via sudo /usr/bin/rootsh -i -u root. Then make some action then go back and carry on with script... Something like

...
ssh -t myserver << EOF 
sudo /usr/bin/rootsh -i- -u root
whoami
#<action on myserver as root>
EOF
...

If I do it this way - doesn't work.

If done in the way

ssh -t myserver 'sudo /usr/bin/rootsh -i -u root ;whoami'

I can do ssh and then switch to root, but then script wait until session/shell closed.

Paulo Tomé
  • 3,754
  • 6
  • 26
  • 38
  • 1
    What is `rootsh`? Why not use `sudo` or `su` to become root directly? Why is this extra thing needed? – Panki Jan 30 '20 at 13:49
  • If you want the script to keep running in the background without waiting for session exit, you can use `nohup` or `command &` and then `disown -h` – Dexirian Jan 30 '20 at 18:36

0 Answers0