Use the Secure Shell protocol to execute commands on a remote server using a private key
Go to siteThe SSH (Secure Shell) key-based authentication API allows you to execute commands on a remote server securely. With Pipedream, leverage this capability to automate server management tasks, execute deployment scripts, or gather data from your server infrastructure. By integrating with other apps on Pipedream, you can create seamless workflows that trigger actions on your servers in response to various events.
module.exports = defineComponent({
props: {
ssh: {
type: "app",
app: "ssh",
}
},
async run({steps, $}) {
const SSH2Promise = require('ssh2-promise')
const {
host,
port,
username,
privateKey,
} = this.ssh.$auth
const ssh = new SSH2Promise({
host,
port,
username,
privateKey,
})
await ssh.connect()
console.log("Connection established")
// Replace this with the command you'd like to run
const resp = await ssh.exec("whoami")
console.log(resp)
await ssh.close()
},
})
Automated Deployment: Trigger a workflow on Pipedream when your code repository (like GitHub) senses a new commit to the master branch. The workflow would initiate an SSH session to your production server and pull the latest code changes, ensuring continuous deployment without manual intervention.
Scheduled Server Maintenance: Set up a scheduled workflow in Pipedream that SSHs into your server to perform routine maintenance such as package updates, cleaning temp directories, or backing up databases. This could be paired with a notification service like Slack to inform your team when maintenance tasks have been completed.
Real-time Server Monitoring and Alerts: Create a Pipedream workflow that periodically SSHs into your server to check system health, like disk space or running services. If it detects an issue, it could send an alert through an app like PagerDuty or send a detailed report to an email via SendGrid, enabling prompt response to potential problems.
Executes a command on a remote device. See SSH lib docs here
SSH (key-based auth) uses API keys for authentication. When you connect your SSH (key-based auth) account, Pipedream securely stores the keys so you can easily authenticate to SSH (key-based auth) APIs in both code and no-code steps.
Enter the hostname and port of the server you'd like to connect to, your username, and the private key you'd like to use to connect.
This app only supports key pair authentication, not authentication via password. If you need to use a username / password to connect to a host, please use the SSH (password-based auth) app, instead.