Socket
Socket
Sign inDemoInstall

simple-sftp

Package Overview
Dependencies
6
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    simple-sftp

Dirt simple sftp via ssh2


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

simple-sftp

Dirt-simple, callback-based, easy-to-use SFTP via ssh2. Downloads and uploads are done via readable and writable streams respectively.

The built-in SFTP capabilities of ssh2 were giving me trouble when connecting to SpringCM via SFTP, and I found that I had to get down to brass tacks and do file open, buffered read, file close. That's exactly what this library does. No crazy multiple reader solutions, nothing fancy: open the file, read it until there's nothing left to read, then close it.

Download a file

const SFTP = require('simple-sftp');

var client = new SFTP();

client.connect({
	hostname: 'sftp.website.com',
	username: 'user@website.com',
	keyfile: 'C:\\Path\\To\\Key\\Here',
	password: 'or_your_password'
}, (err) => {
	if (err) {
		return console.log(err);
	}

	client.get('/path/to/file.txt', (err, stream) => {
		if (err) {
			return console.log(err);
		}

		// Do what you will, e.g. write to a file
		stream.pipe(fs.createWriteStream('./file.txt'));
		stream.on('end', () => {
			client.disconnect();
			process.exit(0);
		});
	});
});

Keywords

FAQs

Last updated on 05 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc