Skip to main content

SSH2

SSH2 gives you a secure way to access a computer over an unsecured network. This integration provides ssh2 with callback 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.

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

SSH2 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.ssh2("credential-slug");
New integration from plain authentication data (username and password)
const { Client } = require("ssh2");

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

const sshConnection = new Client().connect(options);
New integration from plain authentication data (private key)
const { Client } = require("ssh2");

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

const sshConnection = new Client().connect(options);

Interactive Shell Session

Shell session
sshConnection.on('ready', () => {
console.log('Client :: ready');
sshConnection.shell((err, stream) => {
if (err) {
throw err;
}
stream.on('close', () => {
console.log('Stream :: close');
sshConnection.end();
}).on('data', (data) => {
console.log('OUTPUT: ' + data);
});

stream.end("your-command-here\nexit\n");
});
})