Şu anda bir Web tabanlı SSH istemcisi oluşturuyorum. Linux makinesine bağlanmak için düğüm ve SSH2 modülü kullanıyorum. Sorun, sunucunun istemciden "sudo" yanıtı beklediğini belirlemeye çalışıyor. Düğüm, SSh2 Sunucu girdi bekliyor
this.onWsMessage = function(packet) {
log('Message Received from ');
if (cmd != '') {
log('----------------------------------------->' + cmd);
source[this.getId()].sshStream.write(cmd + '\n');
}
};
var client = clients[cid];
sshClient
.on('ready', function() {
console.log('CONNECTED');
sshClient.shell({pty: true}, function(err, stream) {
_shellHandler(err, stream, client);
});
})
.on('error', function(err) {
console.log('ERROR', err);
})
.connect(serverInfo);
}
function _shellHandler(err, stream, client) {
source[client.getId()].sshStream = stream;
stream
.on('close', function() {
log('ssh connection close');
//sshClient.end();
this._client.end();
})
.on('data', function(data) {
console.log(stream);
var msg = data.toString().replace(msgPattern, '');
this.sendUTF(msg, 'ssh');
}.bind(client));
}
Yanıt verdiğiniz için teşekkür ederiz. Yanıtta varsayılan linux istemini izlemek, sunucudaki beklemeleri algılamanın bir yolu olabilir. Çok kullanışlı modül BTW –