袜子版本无效 SOCKS 模块 NODEJS

问题描述

我想通过代理连接到 sftp 服务器来下载文件,我使用socks 和 ssh2-sftp-client 这是我的代码:

let SocksClient = require('socks').SocksClient;
let Client = require('ssh2-sftp-client');
let fs = require('fs');

(async () => {
    try {
         const host = "sftp.xx.xxxxx.xxx";
         const port = 22; // default SSH/SFTP port on remote serv
            
        // connect to SOCKS 5 proxy
        const { socket } = await SocksClient.createConnection({
            proxy: {
                 host: "xxx.xx.xx.xx",port: 22,type: 5,// for SOCKS v5
            },command: 'connect',destination: { host,port } // the remote SFTP server
        });
            
        const sftp = new Client();

        await sftp.connect({
            sock: socket,host: host,port: port,username: "xxxx",// sftp
            password: "xxxx",// password sftp
        })

        console.log('SFTP CONNECTED!')

        await sftp.end();
    } catch(err){
        console.error(err);
    }
})()

但我收到此错误:

SocksClientError: Received invalid Socks5 initial handshake (invalid socks version)

我该如何解决这个问题?我可以使用 ssh 隧道连接到远程 sftp 服务器吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...