Ruby SFTP download script


Some applications have need to download data from remote SFTP server. PHP offers limited choices here. Options boil down to installing ssh2 extension or including phpseclib library to your project, both of which come with too much overhead for something straightforward as SFTP file download.

On the other hand Ruby, which is paired with net-sftp gem ( accomplishes this with ease.

Here is how you can do it too:

Example usage:

After completing download script outputs file name to standard output allowing piping: