Remote Eclipse workspace using SSH

One of the clients I do development for has requested that I do not keep any copy of the code on my laptop. I wanted to be able to do work remotely from my home office but still be able to use Eclipse as an IDE (ie not using Vim or Emacs through ssh). I have a ubuntu desktop machine setup with Eclipse at my client’s that I use when I’m there. I wanted to be able to use the Eclipse workspace remotely with Eclipse running locally (ie not use vnc or other remote desktop solutions).

My setup:

There is a linux server at the clientss that is accessible externally via ssh. To ssh to the desktop at the client’s I need to first ssh to the server and then from there ssh to the desktop.  If you have direct access to the desktop you can skip the first step of the instructions.

laptop ---- INTERNET ----> Server ---- LOCAL NETWORK ----> Desktop

Prerequisites:

  • You need linux/unix machines all the way (I have ubuntu on the laptop, remote desktop and Fedora on the remote server. IT should work with Macs too)
  • Install and run an ssh server on the server and remote desktop (openssh) and open apropriate firewall ports.

Instructions:

  1. Setup ‘direct’ ssh connection to remote desktop:
    1. Create an ssh tunnel via port forwarding of port 2222 locally to port 22 (ssh) on the remote desktop at the client’s (192.168.1.43 is the local ip of the remote desktop at the client’s and server.company.com is the address of the remote server (facing the internet):
      ssh -L 2222:192.168.1.43:22 server.company.com
      This terminal should stay opened to keep the tunnel working.
    2. To make sure it works, open a new terminal and connect to the desktop at the client’s (since the local port 2222 is forwarded to port 22 on the desktop at the client’s) :
      ssh -p 2222 localhost
  2. Use sshfs to mount my remote desktop home folder on my laptop (on ubuntu you can install with ‘sudo apt-get install sshfs’):
    1. Create a folder to mount on locally:
      mkdir ~/remotedesktop
    2. Create an entry in .ssh/config for the server:
      host remotedesktop
          Hostname localhost
          Port 2222
      
    3. Mount the remote desktop home folder locally:
      sshfs remotedesktop: ~/remotedesktop
    4. By default sshfs will mount the home directory but you can specify a path after the semi-column to mount something else.

Voilá! Now you can open Eclipse and point to the the workspace on the remotedesktop:
~/remotedesktop/path/to/workspace
And since you’re tunneling through ssh everything is encrypted.
To unmount the remote desktop home folder:
fusermount -u ~/remotedesktop
After than you can close the terminal that was maintaining the ssh tunnel.

Advertisement

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.