问题描述
我想通过代理连接到 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 (将#修改为@)