Eclipse and SFTP

One of my students at ITP just asked about file sync between one’s local file system to a remote file system using Eclipse and SFTP, so I put together a quick how-to, which might be of interest. The actual text/steps may vary, depending upon your version of Eclipse, but all the basics are there.

The one caveat of this process is that I’ve only been successful in setup and sync with an existing remote directory, and then importing it locally, not the other way around, e.g. exporting local to remote (though I have not tried very hard in this area — for whatever reason, the target has always existed whenever I’ve set up sync). So a remote target folder of some kind must already exist before you sync it to a local one, if you’re using these instructions.

To equate a local directory with a pre-existing remote one:

  1. Help > Software Updates
  2. Choose Available Software Tab
  3. Click Add Site…, and then put http://eclipse.jcraft.com/ for the URL field.
  4. Choose SFTP Plug-in, and then click Install …, and then restart after the install
  5. Using Project Explorer view, make a new local project
  6. Create a folder within that project that will map to a remote folder
  7. Right click on the local folder in Project Explorer and choose Import
  8. In the Select dialog, choose Other > SFTP
  9. Choose the local folder as the one to receive the import
  10. Create a new SFTP site and give your host and login info
  11. If successfully connected to remote site, you should get the remote directory tree
  12. Choose the remote folder to import
  13. The remote files should now be in the local folder

Now to keep sync between these two:

  1. Go to Window > Show View > Other… > Team > Synchronize
  2. Click the first upper right icon in the Synchronize tab
  3. Choose SFTP from the Synchronize dialog
  4. The previously mapped folder should appear with all files selected
  5. Click Finish
  6. Eclipse will ask you if you want to use Team Synch perspective. Personally I don’t use this. I just keep the Synchronize view as part of my workbench

To test:

  1. Make a change in a file within the local folder
  2. It should then appear in the Synchronize view in Outgoing mode
  3. Using the buttons at the top of the Synchronize tab, or the right-click menus on any of the items that have changed, you can upload or check the diff between the local and remote counterpart

So there you have it. For projects that involve multiple people, I would recommend using a version control system like Subversion, but for quick one-person, one code-base jobs, this works nicely …

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 )

Google+ photo

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

Connecting to %s