Guest User

Untitled

a guest
Jan 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. const Ssh = require('node-ssh');
  2.  
  3. async function main() {
  4. const ssh = new Ssh();
  5.  
  6. const sshPassword = 'SSH_PASSWORD';
  7.  
  8. // connect
  9. await ssh.connect({
  10. host: 'SSH_HOST_ADDRESS',
  11. port: SSH_PORT,
  12. username: 'SSH_USER_NAME',
  13. password: sshPassword
  14. });
  15.  
  16. // execute command
  17. res = await ssh.execCommand('ls -al', {options: {pty: true}});
  18. console.log(res);
  19.  
  20. // disconnect
  21. ssh.dispose();
  22. }
  23.  
  24. main();
Add Comment
Please, Sign In to add comment