Check out
this article for some detailed discussion on how to setup RMI over SSH. I should mention that the motivation for the article came from the discussion in this
thread (And I acknowledge it in the article
).
One thing I discovered after sending out the article is that there exists an elegant way to specify the hostname
string that gets associated with remote stubs for locally created remote objects. This is done by setting the Java system property
to the desired value (which should be "localhost" for SSH tunneling), as explained in the
official RMI documentation. This capabilitiy actually makes SSH tunneling for RMI much more elegant and easy to setup.