Skip to main content

SSH2 Promise

SSH2 gives you a secure way to access a computer over an unsecured network. This integration provides ssh2 with asynchronous functions

Network Connection needs

This integration needs network access to the server where the service is running.

See the Network access page for details about how to achieve that.

SSH2 Promise snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const sshConnection = yepcode.integration.ssh2Promise("credential-slug");
New integration from plain authentication data (username and password)
const SSH2Promise = require("ssh2-promise");

const options = {
host: "hostname",
port: portNumber,
username: "username",
password: "password",
};

const sshConnection = await new SSH2Promise(options).connect();
New integration from plain authentication data (private key)
const SSH2Promise = require("ssh2-promise");

const options = {
host: "hostname",
port: portNumber,
username: "username",
privateKey: "privateKey",
};

const sshConnection = await new SSH2Promise(options).connect();

Execute shell commands

Exec shell command (promise)
sshConnection.exec("your-command").then((data) => {
// Use the received data
console.log(data);

sshConnection.close();
});
Exec shell command (async/await)
const data = await sshConnection.exec("your-command");

// Use the received data
console.log(data);

sshConnection.close();