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

Tagsshell
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.

Credential configuration

To configure this credential you need the host, port and username to connect to the SSH server. Additionally, you'll need a password or the private key depending on how you want to connect.

Optionally, you can set any of the extra config parameters you can see here, in the constructor method.

Here is an example of a filled credential configuration form in YepCode:

SSH2 Promise snippets available in 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();