RVM is not working over SSH.
At the command-line:
leifg@host:~$ which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
Connected
Actually there's totally another, more safe and lightweight option.
You add "PermitUserEnvironment yes" somewhere to your sshd_config in /etc/(open)ssh
Now you are allowed to specify user environment in /home/user/.ssh/environment. So what do you put there ?
Just something like :
user# env | grep rvm > ~/.ssh/environment
so it looks like below :
user@app3:~$ cat ~/.ssh/environment rvm_bin_path=/usr/local/rvm/bin GEM_HOME=/usr/local/rvm/gems/ree-1.8.7-2012.02 IRBRC=/usr/local/rvm/rubies/ree-1.8.7-2012.02/.irbrc MY_RUBY_HOME=/usr/local/rvm/rubies/ree-1.8.7-2012.02 rvm_path=/usr/local/rvm rvm_prefix=/usr/local PATH=/usr/local/rvm/gems/ree-1.8.7-2012.02/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games rvm_version=1.14.5 (stable) GEM_PATH=/usr/local/rvm/gems/ree-1.8.7-2012.02:/usr/local/rvm/gems/ree-1.8.7-2012.02@global
Note: this also works work user-install RVM (not only for the system wide)
Now your are able to use ruby in ssh non interactive sessions :
ssh user@app3 'ruby --version' ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02
Voila!