SSH 连接 Java
是否可以使用java与服务器建立ssh连接?
Is it possible to make a ssh connection to a server with java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以使用java与服务器建立ssh连接?
Is it possible to make a ssh connection to a server with java?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
是的,我在 Java 应用程序中使用了 http://sourceforge.net/projects/sshtools/通过 SSH 连接到 UNIX 服务器,效果很好。
Yes, I used http://sourceforge.net/projects/sshtools/ in a Java application to connect to a UNIX server over SSH, it worked quite well.
jsch 和 sshJ 都是很好的客户端。我个人会使用 sshJ,因为代码的文档记录得更彻底。
jsch 有着广泛的使用,包括在 eclipse 和 apache ant 中。我也遇到了 jsch 和 AES 加密私钥的问题,需要在 3DES 中重新加密,但这可能只是我的问题。
jsch and sshJ are both good clients. I'd personally use sshJ as the code is documented much more thoroughly.
jsch has widespread use, including in eclipse and apache ant. I've also had issues with jsch and AES encrypted private keys, which required re-encrypting in 3DES, but that could just be me.
是的,这是可能的。您可以尝试以下代码:
Yes, it is possible. You can try the following code:
要连接到 Java 服务器,您需要 SSHD 的实现(ssh 客户端还不够)。您可以尝试 Apache SSHD,
http://mina.apache.org/sshd/
因为 sshd 是已经在大多数系统上运行,一个更简单的替代方案是通过 SSH 隧道连接到服务器。
To make connection to Java servers, you need an implementation of SSHD (ssh client is not enough). You can try Apache SSHD,
http://mina.apache.org/sshd/
Because sshd is already running on most systems, an easier alternative is to connect to the server through a SSH tunnel.