简体   繁体   English

如何在java(jsch)中向/从SSH隧道发送和获取数据?

[英]How to send and get data to/from SSH Tunnel in java (jsch )?

I am a begginer to SSH Tunnels and I am trying to find a way to implement an SSH tunnel between host and server and through this tunnel, I want to send and get datas. 我是SSH隧道的初学者,我正在尝试找到一种在主机和服务器之间实现SSH隧道的方法,通过这个隧道,我想发送和获取数据。 I have searched on the net and I have seen that " jsch " can help me to implement a tunnel. 我在网上搜索过,我看到“jsch”可以帮我实现一个隧道。 The problem is since there was not enough comments on http://www.jcraft.com/jsch/examples/ I could not understand how to do it. 问题是因为http://www.jcraft.com/jsch/examples/上没有足够的评论我无法理解如何做到这一点。 If one of you knows about how to do it, can you please explain me ? 如果你们其中一个人知道怎么做,你能解释一下吗? Or if you have a little piece of code, can you please put with some comments ? 或者,如果您有一小段代码,可以请一些评论吗?

Thank you very much all 非常感谢你们

Why do you want to do it in java ? 你为什么要在java中这样做?

You'd better create a dynamic tunnel with ssh/PuTTY and use it in java thus ignoring the SSH complexity in your java code... 你最好用ssh / PuTTY创建一个动态隧道并在java中使用它,这样就忽略了java代码中的SSH复杂性......

A dynamic tunnel is no more no less than a SOCKS 5 proxy which can easily be dealt with Java networking and Proxy + ProxySelector objects 动态隧道不亚于SOCKS 5代理,可以轻松处理Java网络Proxy + ProxySelector对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM