Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ssh

SS2 with Promises


Version published
Weekly downloads
109K
decreased by-0.15%
Maintainers
1
Weekly downloads
 
Created

What is node-ssh?

The node-ssh npm package is a lightweight wrapper for SSH2, providing a simple and easy-to-use API for performing SSH operations. It allows you to connect to remote servers, execute commands, transfer files, and manage SSH connections programmatically.

What are node-ssh's main functionalities?

Connecting to a remote server

This feature allows you to establish an SSH connection to a remote server using the provided host, username, and private key.

const { NodeSSH } = require('node-ssh');
const ssh = new NodeSSH();
ssh.connect({
  host: 'example.com',
  username: 'user',
  privateKey: '/path/to/private/key'
}).then(() => {
  console.log('Connected to the server');
}).catch(err => {
  console.error('Error connecting to the server:', err);
});

Executing commands on a remote server

This feature allows you to execute shell commands on the connected remote server and retrieve the output.

ssh.execCommand('ls -la', { cwd: '/home/user' }).then(result => {
  console.log('STDOUT: ' + result.stdout);
  console.log('STDERR: ' + result.stderr);
}).catch(err => {
  console.error('Error executing command:', err);
});

Transferring files to a remote server

This feature allows you to transfer files from your local machine to the remote server.

ssh.putFile('/local/path/to/file.txt', '/remote/path/to/file.txt').then(() => {
  console.log('File transferred successfully');
}).catch(err => {
  console.error('Error transferring file:', err);
});

Transferring files from a remote server

This feature allows you to download files from the remote server to your local machine.

ssh.getFile('/local/path/to/file.txt', '/remote/path/to/file.txt').then(() => {
  console.log('File downloaded successfully');
}).catch(err => {
  console.error('Error downloading file:', err);
});

Other packages similar to node-ssh

Keywords

FAQs

Package last updated on 19 Jul 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc