I would like to use some JM开发者_Go百科S (Java Message Service) library, ActiveMQ or FFMQ, but need to run it over SSH protocol. I have started implementing my own connection factory method of ActiveMQ, but then the idea of implementing Socket/SocketFactory interfaces over SSH has struck me. It would let me adapt pretty much any JMS implementation without really touching its code. As usual, somebody has already had this idea and I have found couple implementations of this approach.
http://svn.apache.org/repos/asf/pig/trunk/lib-src/shock/org/apache/pig/shock/SSHSocketImplFactory.java http://benkstein.net/java/SSHSocketFactory/javadoc/
The first one is a class somewhere in the guts of Apache Pig. The second is a hack/addon for MySQL client, published by Frank Benkstein in 2004. It appears that MySQL community was not interested in it (http://www.webservertalk.com/archive277-2004-7-294282.html).
I wonder if there are other implementations of SocketOverSsh factory, possibly better documented/supported?
Update: My primary motivation is to avoid having additional open ports or configuration changes both on the client and the server. So SOCKS or plain port forwarding are not desirable solutions.
This looks a bit heavy-weight. Have you considered finding a solution using the SOCKS protocol? An ssh-client can act as a SOCKS proxy by e.g. invoking it with "ssh -D ". The good thing is that the JVM already knows how to use SOCKS automatically for network connections. Of course the cave-at is that the ssh-connection would be established outside of the Java app.
精彩评论