如何在java(jsch)中向/从SSH隧道发送和获取数据?
我是 SSH 隧道的初学者,我正在尝试找到一种在主机和服务器之间实现 SSH 隧道的方法,并通过该隧道发送和获取数据。我在网上搜索过,我看到“jsch”可以帮助我实现隧道。问题是因为 http://www.jcraft.com/jsch/examples/ 上没有足够的评论 我不明白该怎么做。如果你们中有人知道如何做,您能解释一下吗?或者如果您有一小段代码,可以添加一些评论吗?
非常感谢大家
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. I have searched on the net and I have seen that " jsch " can help me to implement a tunnel. The problem is since there was not enough comments on http://www.jcraft.com/jsch/examples/ I could not understand how to do it. 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要用java来做呢?
您最好使用 ssh/PuTTY 创建动态隧道并在 java 中使用它,从而忽略 java 代码中的 SSH 复杂性...
动态隧道不亚于 SOCKS 5 代理,可以轻松处理Java 网络 和
代理
+ ProxySelector 对象Why do you want to do it in 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...
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