File Exchange Pick of the Week

Our best user submissions


Jiro's pick this week is "SSH/SFTP/SCP For Matlab (v2)" by David Freedman.

Recently, we changed our internal server for our blogs, and now we are using Secure FTP to upload images and files. When we were using the old system (FTP), many of us used MATLAB's ftp or Passive Mode FTP (Picked by Sean) to automate the file transfer.

With the new system, I needed an SFTP-equivalence to the ftp function. Of course, I looked to the File Exchange! David's entry is a well-written package that interfaces to an open-source Ganymed SSH-2 Java library. The entry comes with a version of the library, but it can also be set up to download a version from the web. The setup is very simple and seamless. What I also like about this entry is that David provides simple interface commands to SSH/SCP/SFT, as well as advanced interface functions.

The simple interface works like this:


With a single command, you specify the server, the files, and the location you want to upload to.

If you want more control, the advanced interface works like this:

% Create a connection
s_conn = ssh2_config('','username','password');

% Run a command, such as "create a folder"
ssh2_command(s_conn,'mkdir /var/host/user/temp');

% Copy files from local to remote

% Close the connection

David has documented the functions well and also has included examples for you to try. Thanks, David, for making this transition from FTP to SFTP so simple!


Give this a try, and let us know what you think here or leave a comment for David.

Published with MATLAB® R2016a

  • print
  • send email


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.