I am trying to run a script which executes a chain of commands under another user on a remote server. The script contains the following ssh command to return information about the remote user's Drupal installation. My sudoers user's public key is in place and working properly.
The following example does not work and just stops without any output:
$ssh [email protected] "sudo -u another_user -s;cd ~/htdocs;drush status;"
When I enter the chained commands manually in the console it works fine.
I do also get good results with:
$ssh [email protected] "ls -al /var/www/vhosts/"
Please advise where I go wrong. Thank you.
sudoers_user
and thensudo -s
to another user? If you coulr ssh asanother_user
directly, that'd save you some trouble. I'd check the /etc/sudoers file, and also the logs; if you've got a failed sudo attempt it would probably be logged...