The other question that you reference answers your question perfectly, except for the fact that Drush is located in a different location on that user's remote system. Since drush @remote ssh
works for you, type which drush
on the remote system, to find out where your Drush is located. You are likely to get an answer similar to /home/USER/.composer/vendor/bin/drush
. You need to insure that the directory /home/USER/.composer/vendor/bin
is in your PATH. This directory might vary if you did not install Drush using Composer, as recommended in the Drush README.
If which drush
produces no output at all, this means that you forgot to install Drush on the remote machine. Use composer, following the same instructions you would for your local machine, in the above-referenced README file.
Pay particular attention to the following part of the installation instructions:
Add Composer's global bin directory to the system PATH (recommended):
sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
source $HOME/.bashrc
The 'sed' line shown above adds an export PATH
statement to the TOP of your .bashrc file. It is important to set your PATH early, because .bashrc exits just a few lines in when running in non-interactive mode on most Linux distributions. Most of the other places you might be tempted to set the PATH (.profile, etc.) are not sourced at all in non-interactive mode. So, if you do not set the PATH in the right place, then Drush will work from an interactive shell (e.g. after drush @remote ssh
), but most remote Drush commands (e.g. drush @remote status
) will not.