nodejs ssh2 输出调试信息

在使用nodejs ssh2库时,我们可能需要输出调试信息,输出调试信息在连接时调用connect函数就可以使用debug字段设置。如下:

var Client = require('ssh2').Client;

var host = {
    "debug": function (err) {
        console.log(err);
    },
    "host": "192.168.1.18",
    "port": 22,
    "username": "name",
    "password": "pass",
    "algorithms": {
        "kex": ["diffie-hellman-group1-sha1"],
        "cipher": ["aes128-cbc"]
    }
};

var conn = new Client();
conn.on('ready', function () {
    console.log('ready ---');
}).on("error", function (err) {
    console.log("xxx" + err);
}).connect(host);

猜你喜欢

转载自blog.csdn.net/llmys/article/details/80806458
今日推荐