简体   繁体   English

使用jsch进行远程端口转发?

[英]Remote port forwarding using jsch?

I am using the library jsch to make ssh connection. 我正在使用jsch库建立ssh连接。 I am useing following code; 我正在使用以下代码;

JSch jsch = new JSch();
Session session = jsch.getSession("username", "host", port);

But how to put some specific option while I am creating the connection? 但是,在创建连接时如何放置一些特定选项? Actually I want to replicate; 实际上我想复制;

ssh -R abc:8080:localhost80 mysite.com ssh -R abc:8080:localhost80 mysite.com

  • This command using jsch. 此命令使用jsch。

Is it possible using jsch? 是否可以使用jsch? Or I should use some other library. 或者我应该使用其他图书馆。

Any suggestion will be very helpful. 任何建议都会非常有帮助。

Thanks in advance. 提前致谢。

Is it more options than port forwarding that you need? 除了您需要的端口转发以外,还有更多选择吗?

Port forwarding (as in -R ) is possible with JSch - example here . JSch- example可以在这里进行端口转发(与-R )。

If the objective is emulating the OpenSSH command line options, this would be tougher. 如果目标是模拟OpenSSH命令行选项,这将更加困难。 To the best of my knowledge, all the various SSH libraries for Java, JSch included, focus on providing connectivity for applications that need SSH support. 据我所知,包括JSch在内的所有各种Java SSH库都致力于为需要SSH支持的应用程序提供连接。 That sounds like it would need a small project in command line parsing. 听起来好像在命令行解析中需要一个小项目。

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

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