./categories/back-end
Node.js node-ssh 클라이언트
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();
});
관련 링크: https://lts0606.tistory.com/46
./comments