Created
January 19, 2019 17:45
-
-
Save pirosuke/c3da245490eb42de6c3ab344ea0cde38 to your computer and use it in GitHub Desktop.
Sample To Print Files In Directory Through SSH Using Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Ssh = require('node-ssh'); | |
async function main() { | |
const ssh = new Ssh(); | |
const sshPassword = 'SSH_PASSWORD'; | |
// connect | |
await ssh.connect({ | |
host: 'SSH_HOST_ADDRESS', | |
port: SSH_PORT, | |
username: 'SSH_USER_NAME', | |
password: sshPassword | |
}); | |
// execute command | |
res = await ssh.execCommand('ls -al', {options: {pty: true}}); | |
console.log(res); | |
// disconnect | |
ssh.dispose(); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment