2
ssh에 관한 질문이 있습니다.nodejs + ssh2 + nodessh
var Connection = require('ssh2');
var c = new Connection();
c.on('connect', function() {
console.log('Connection :: connect');
});
c.on('ready', function() {
console.log('Connection :: ready');
c.exec('uptime', function(err, stream) {
if (err) throw err;
stream.on('data', function(data, extended) {
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ')
+ data);
});
stream.on('end', function() {
console.log('Stream :: EOF');
});
stream.on('close', function() {
console.log('Stream :: close');
});
stream.on('exit', function(code, signal) {
console.log('Stream :: exit :: code: ' + code + ', signal: ' + signal);
c.end();
});
});
});
c.on('error', function(err) {
console.log('Connection :: error :: ' + err);
});
c.on('end', function() {
console.log('Connection :: end');
});
c.on('close', function(had_error) {
console.log('Connection :: close');
});
c.connect({
host: 'ip',
port: 22,
username: 'root',
password: 'pass'
});
나는 그것을 실행하려고 시도했지만 서버에 연결하여 끝내고 닫는 기능을 수행합니다. 나는 서버가 켜져 있는지 확인했다. ssh2와 쉘에서 연결을 만들었 기 때문에 내 copypaste 코드에 실수가 있어야합니다. 내가 도대체 뭘 잘못하고있는 겁니까?