I have created a Jenkins job today, what it does is the Jenkins user should log into another server and run two commands separated by &&:
ssh -i /creds/jenkins [email protected] "sh -c 'sudo su && lxc exec containername bash'"
The logging part works fine, then it runs the sudo su
command and becomes root but it never runs the second command.
I even did this manually and from the Jenkins machine logged into the other server (servername). Then ran sh -c "sudo su && lxc exec containername bash"
with no luck.
Try to execute the second command as a parameter for the
sudo su
command, like this: