tunnel-ssh

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/adley_app/article/details/87604795

nodejs建立ssh隧道。类似ssh -L

const tunnel = require('tunnel-ssh');

const config = {
    keepAlive: true,

    // host1
    host: sshServer, // '106.xx.xxx.xx'
    username: 'root',
    Password: 'secret',
    port: 22,

    // 内网主机/目标主机 host2 
    dstHost: destinationServer, // '10.xx.xxx.x'
    dstPort: 27017,

    // 本地host port
    localHost: '127.0.0.1',
    localPort: 27000
};


const server = tunnel(config, function (error, server) {
    if(error){
        console.log(error);
        return;
    }

    console.log('SSH tunnel connected');
});

猜你喜欢

转载自blog.csdn.net/adley_app/article/details/87604795
今日推荐