java jsch proxy forwarding - PullRequest
       18

java jsch proxy forwarding

1 голос
/ 16 февраля 2020

Я хотел отправить входящие сетевые данные с устройства на S SH, но я не могу открыть канал

JSch sshclient = new JSch();
java.util.Properties config = new java.util.Properties();
Session sshsession =  sshclient.getSession("username", "ssh.ssh.com", 22);
sshsession.setPassword("password");
config.put("StrictHostKeyChecking", "no");
sshsession.setConfig(config);
sshsession.setProxy(new ProxyHTTP("127.0.0.1",8080)); // local Proxy server running on port 8080
sshsession.connect();
// the above code works, the part below is im unsure
int assignedPort = sshsession.setPortForwardingL(7935, "ssh.com", 22); // not sure here where to connect whether the SSH or the local proxy but I'd like to open a local port at 7935 where ill connect SOCKS5 proxy clients
Channel channel = sshsession.openChannel("direct-tcpip");
((ChannelDirectTCPIP)channel).setHost("127.0.0.1");
((ChannelDirectTCPIP)channel).setPort(8080); 
InputStream in =channel.getInputStream();
OutputStream out = channel.getOutputStream();
channel.connect(); //stops here, doesnt continue

Он должен работать как -proxyFwding * bitvise *, где он открывает туннель прокси, где я могу подключить клиентов, таких как веб-браузеры, но я не уверен, есть ли у jsch эта функция или мой код просто неверен

...