nugawiki

./categories/back-end

Node.js node-ssh 클라이언트

업데이트 2026-07-21 조회수
npm install node-ssh
var node_ssh = require('node-ssh');
var ssh = new node_ssh();

ssh.connect({
  host: 'HOST',
  username: 'USER',
  port: 22,
  password: 'PASS',
  readyTimeout: 20000
}).then(function () {
  return ssh.execCommand('명령어', {});
}).then(function (result) {
  console.log(result.stdout);
  console.log(result.stderr);
  ssh.dispose();
});

// 파일 받기
ssh.getFile('로컬경로', '원격파일').then(function () {
  ssh.dispose();
});

// 파일 보내기
ssh.putFiles([{ local: '보낼파일', remote: '원격경로' }]).then(function () {
  ssh.dispose();
});

./comments