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

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 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.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");
});
})