连接到 sftp 服务时节点 js 出错

时间:2021-03-10 18:32:04

标签: node.js sftp

尝试连接时出现此错误... SSH - 连接错误:错误:等待握手时超时 尝试连接时出现此错误... SSH - 连接错误:错误:等待握手时超时

这是我的代码

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

conn.on ('error', function (err) {
    console.log ('SSH - Connection Error:' + err);
});

conn.on ('end', function () {
    console.log ('SSH - Connection Closed');
});

conn.on ('ready', function () {
    console.log ("------ enter ------");

    // code to work with SSH
});
conn.connect ({
    host: 'host',
    port: 22, // Normal is 22 port
    username: 'user',
    password: 'pass',
});

0 个答案:

没有答案