Wednesday, November 25, 2009

ssh/sftp in java

Some years ago, we had to deal with SFTP file transfers. We solved the problem by reusing the Apache licensed projects Commons VFS and the org.apache.commons.vfs.provider.sftp.SftpFileProvider class. This reuses the jsch library, and after having to troubleshoot some issues wrt threads and strange disconnections, it left a sour taste in my mouth. (jsch code isn't really my taste, and there's little logging for example, even though the author praises openssh's -v arguments. I don't want to diminish the author's accomplishments, but debugging production server issues with a debugger isn't fun).

I've found the Trilead project, but this project is unsupported now. Latest code is available e.g. from here.

Then another blog entry (also rambling on the code quality of the jsch project...) led me to commons-net-ssh, which sounds like a compelling alternative for SFTP file transfers.

Apache licensed, it looks active, somewhat documented and with a couple of unit tests...

The README says "GSOC project "SSH and SCP for Apache Commons-Net"", and this blog entry hints that the project should be retrofitted one day into apache commons-net. Can't wait for that.

2 comments:

  1. You can use Apache Mina too : http://mina.apache.org/sshd/

    ReplyDelete
  2. You're right! The last link in my entry actualy states that "thanks to the efforts of the Mina SSHD project, whose codebase we originally based the effort on".

    I guess it all depends on the level of abstraction. From an application that only cares about transferring a file, maybe commons-net is more appropriate? If someone wants to do lot's of fun stuff through ssh, maybe Mina is better ?

    ReplyDelete