Problem: I have a remote server with SSH access where the Drupal site can only be accessed as another user (www-data). My own shell user is not able to use drush directly for security reasons.
So how can I run all drush remote commands as www-data? I have sudo priviledged to execute commands as root.
My aliases.drushrc.php:
<?php
$aliases['accounting-phd'] = array(
'root' => '/var/www/example/docroot',
'uri' => 'example.com',
'remote-host' => 'server.example.com',
'ssh-options' => '-t',
'path-aliases' => array(
'%drush-script' => '/home/klausi/drush-remote.sh',
),
);
And in drush-remote.sh on the server:
#!/bin/bash
sudo su www-data -c "drush $@"
This prompts me for my password successfully, but then fails with
su: unrecognized option '--root=/var/www/example/docroot'
Usage: su [options] [LOGIN]
How can I separate the options from the su command?