Socket
Socket
Sign inDemoInstall

ssh2-sftp-client

Package Overview
Dependencies
10
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ssh2-sftp-client

ssh2 sftp client for node


Version published
Weekly downloads
411K
decreased by-4.33%
Maintainers
1
Install size
0.967 MB
Created
Weekly downloads
 

Readme

Source

SSH2 SFTP Client

a SFTP client for node.js, a wrapper for ssh2

Installation

npm install ssh2-sftp-client

Usage

let Client = require('ssh2-sftp-client');
let sftp = new Client();
sftp.connect({
    host: '127.0.0.1',
    port: '8080',
    username: 'xx'
    passphrase: 'xxx'
}).then(() => {
    return sftp.list('/pathname');
}).then((data) => {
    console.log(data, 'the data info');
}).catch((err) => {
    console.log(err, 'catch error');
});

Documentation

the connection to server config pls see ssh2 client event.

list of methods: all the methods will return a Promise;

List

Retrieves a directory listing.

sftp.list(romoteFilePath)

directory info:

type: // file type(-, d, l)
name: // file name
size: // file size
modifyTime: // file timestamp of modified time
accessTime: // file timestamp of access time
rights: {
    user:
    group:
    other:
},
owner: // user ID
group: // group ID
Get

get a new readable stream for path.

sftp.get(romoteFilePath, [useCompression]);
Put

upload a file. it can be localPath or Buffer or Stream.

sftp.put(localFilePath, remoteFilePath, [useCompression]);
sftp.put(Buffer, remoteFilePath, [useCompression]);
sftp.put(Stream, remoteFilePath, [useCompression]);
Mkdir

create a new directory.

// recursive default is false, if true, it will create directory recursive
sftp.mkdir(remoteFilePath, recursive);
Rmdir

remove the directory or file.

// recursive default is false, if true, it will remove directory recursive even if is not empty
sftp.rmdir(localPath, recursive);
Delete

delete file.

sftp.delete(remoteFilePath);
Rename

rename/remove remoteSourcePath to remoteDestPath.

sftp.remove(remoteSourcePath, remoteDestPath);

FAQ

TODO

to do...

Keywords

FAQs

Last updated on 10 Apr 2016

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