I know, I know, you’ve been waiting your whole life for this.

Download beta SFTP Processing library (source included in zip).

Download example Processing sketch.

The library uses JSch (Java Secure Channel).
Copyright (c) 2002,2003,2004,2005,2006,2007 Atsuhiko Yamanaka, JCraft, Inc.

import sftp.*;

Sftp sftp;

void setup() {
  size(200,200);
  background(0);
  // Create the SFTP object
  // if 3rd arg = false, you must set the password in your code
  // if 3rd arg = true, you will be prompted to enter your password
  sftp = new Sftp("www.hostname.com","login", true);
  // sftp.setPassword("XXXXXX");
  sftp.start(); // start the thread
  noLoop();
}

void mousePressed() {
  // At any point you can execute an SFTP command
  // Not all commands are currently implemented
  // but you do have "ls" and "get"
  // Gosh, I should implement "put", sorry!
  sftp.executeCommand("ls");
  sftp.executeCommand("get file.txt");
}

5 Responses to “Sftp with Java / Processing”  

  1. 1 Peter Kirn

    Excellent … but now I think Amazon S3 support must be next. :) I’ll let you know how I fare. Everything’s documented for, like, real programmers with jobs and such, instead of … erm … me.

  2. 2 Tiago Pedras

    Hey, this is great! But what about that “put” function?
    Does it exist? Can I upload or does it only have download?

    Regards

  3. 3 Daniel

    No sorry, I never got around to it. If you look at the source though, you can see where to add it. I will try to take care of it soon though!

  4. 4 Tiago Pedras

    It’s too bad. =)
    I can’t seem to find a better alternative to use SFTP and yours seemed really nice. Couldn’t get it to work though due to the “libraries” folder miss location (can’t find where to put your files).

  5. 5 shikhar

    plug: give sshj (http://github.com/shikhar/sshj) a shot

Leave a Reply