Home > Enterprise >  ssh exit out of sudo -Es in script
ssh exit out of sudo -Es in script

Time:08-11

I have a script, where I need to run the following:

ssh ${USER}@${HOST}
USER@HOST $ sudo -Es
root@HOST $ chown -R root:root pki
root@HOST $ mv pki /etc/kubernetes/

I tried to make it into one line, to be able to automate it:

ssh [email protected] sudo -Es; chown -R root:root pki; mv pki /etc/kubernetes/

Problem is that it hangs in root user on the remote computer. How would you do it?

CodePudding user response:

The unescaped ;s terminate commands on the local host; they are not passed as literal characters to the remote shell. You also need the second commands to be executed by the new shell, rather than waiting for the new shell to complete.

ssh [email protected] "sudo -Es 'chown -R root:root pki; mv pki /etc/kubernetes/'"
  • Related