My program connects to an IRC room on freenode.net, it uses port 6667, apparently that port is blocked in my college so the project doesn't work there (I wish I had known that before I proposed that one, but it's due the next week so I can't make a new project now). I read that it was possible to tunnel that connection, but I'm not sure how to do it.
I read I had to use an SSH library but I can't find one that helps me tunneling the connection using a socket.
I found a package called ssh in MindTerm but a really old one, that basically does the process (I think) using these lines:
SSHSocketFactory fact = new SSHSocketFactory("ssh.freessh.biz", 22, new SSHPasswordAuthenticator("freessh", "7QO5dkmg<"));
ventanachat.socket = fact.createSocket(servidorirc, puerto);
It gives me: java.io.IOException: MindTerm do not support SSHv2 yet, enable SSHv1 compatibility in server
So I tried a new version that has ssh2 support, but I just can't get the same process since classes are different here and there's no documentation.
The socket is basically Socket socket = new Socket ("irc.freenode.net", 6667);
I am wondering what library could I use, and how?
You are liable to get into trouble for circumventing blocks of the IRC port.
I've got another idea. Download and install IRC server software on the machine you are doing development on. Then you should be able to connect to it from your client without anything blocking the port. (And if you still run into port problems, just configure the client and server use a different one.)
Alternatively, look at the answers to this SO question: Simple SSH Tunnel in Java
There's a couple of SSH libraries for Java present on the market and most of them support SSH tunneling. We offer SecureBlackbox product (Java edition) which has samples (including tunneling), documentation and support.
Ganymed and Jsch both support SSH tunnelling, and both are free.
Related
I want to implement application working on Internet (I have remote Devices connected using Internet), I want to develop Java application to perform changes on remote devices....
I found this link example/code (http://twit88.com/blog/2007/12/22/java-writing-an-automated-telnet-client/) working in Telnet but is insecure I want to use SSH.
JSCH can help me (http://www.jcraft.com/jsch/)? or have you another alternative.
If you have similar code....
Thank you
JSch is be the best solution.
You can use my code snippet as an example:
https://gist.github.com/kobylinsky/1c2b21c73b68a0daa91f
I want to create an application which will connect to a file server and download a few video files. The server is a shared hosting Linux server.
I don't want code or anything like that, I just want to know whether this is possible and if so, what should I be researching. Should I be using java sockets? Or can Java sockets only connect to java based servers?
Should I be using java sockets?
Depends on the type of server you connect to. You can use an existing library which will abstract the interaction with the server for you (recommended) or implement the required protocol yourself (not recommended).
Can Java sockets only connect to java based servers?
Sockets in Java are just an interface to the native socket API of the OS you are on. Every program that connects to a server over the network has to use them, regardless of whether it is a C/C++/Python/Java/... application. So, to answer your question; no, "Java sockets" can connect to any server.
Read more about sockets in this Wikipedia article about sockets in general or this one about Berkeley sockets (the socket API implemented by most operating systems).
I'm looking for a secure way to tunnel RMI traffic.
In My application(java Webstart) i must assume that the only port that is open is port 80.
I have the looked att socketfactories for rmi but do i really need a proxy then.
I need to do all my tunneling on the client side.
The only firewall i am trying to get past is on the client side.
I'm not able to open 1099 with port ranges above.
Would be nice to see some implementations.
Thanks!
Port 1099 was reserved for RMI at IANA in about 1995. There is no reason for it not to be open for outbound access in the client-side firewall.
RMI can be made to use fixed port numbers by supplying a port number when constructing (super(port)) or exporting (exportObject(object, port)). Better still, if you create the Registry within the server JVM via LocateRegistry.createRegistry(), all subequently exported remote objects will use that port unless they specify a different port or they use a server socket factory.
BUT ... RMI already includes HTTP tunneling 'out of the box'. No external solution required. You have to deploy the RMI-Servlet provided with the JDK, at the server end.
(a)
although not the newest fashion, exposing remote services with Hessian and Burlap seems to be a simple solution to avoid problem working across firewalls: http://hessian.caucho.com/doc/
see sample code for the server and client side:
http://www.javatpoint.com/spring-remoting-by-hessian-example
(b) or consider using Spring HttpInvokder (see some sample code here: http://www.javatpoint.com/spring-remoting-by-http-invoker-example)
HttpInvokder provides more customization options through the RemoteInvocationFactory, RemoteInvocationExecutor and HttpInvokerRequestExecutor strategies (for example, to add custom context information (such as user credentials) to the remote invocation, or using java’s built-in object serialization etc.), see:
http://docs.spring.io/spring-framework/docs/2.0.x/api/org/springframework/remoting/support/RemoteInvocationFactory.html
Is it possible to make my local computer function as a gateway in Java? I need the other local machines to connect directly to my computer to see if they are alive or not.
You could run a Java server program on your desired PC and let it listen on a port. Then you could use other programs (browser, other Java programs etc.) to connect to this port, and send commands to be executed by the Java server program.
If you just want to see if the PC is turned on or not, I'd just use the ping command though. Or see this answer: How to do a true Java ping from Windows?
Surely it's the other way round? Surely you want to connect to the other machines to see if they're alive? In which case see InetAddress.isReachable().
Try this.
Create a Java Server Socket, which keeps listening to the client at some port.
Write a client in Java which connects to the Server, wrap the connection logic in try-catch block....
If your host is alive the try code is executed which contains the code to connect to the
Server, if this connection process fails you will get UnknownHostException, here you can instead type a message that the connection failed.
You could more easily manage and control this by polling for other devices from a central server. If possible, avoid unnecessary client/agent apps that might tax your development and support resources as well as taking up RAM on the client workstations.
There are many monitoring tools that already do what you want. I'd have a look at Nagios, for example.
If you want to develop your own app, do your own quick troubleshooting, or just get a feel for network discovery tools, then take a look at NMAP. You could, for example, search a subnet for anything that responds to TCP:445 and see what Windows machines are alive.
If you do go the Nmap route, please have a look at Nmap4j on Sourceforge. It's a Java wrapper API that simplifies the work needed to integrate Java and Nmap.
Cheers!
I have a device in network. I would like to use SNMP to get information. Is it possible for using SSH and then SNMP for messages over ssh session ? I am using Java for implementation.
It seems snmp4j is not yet ready for the snmp via ssh.
Can you please give me some example, if its possible ?
Ideally, you should write your application software developers and ask them to support RFC5592, which is the standard for how to do "SNMP over SSH". Not every stack has support for it yet, but some do (like the most recent version of Net-SNMP).
Normally, SNMP runs over UDP; the SNMP implementations I know cannot directly use SSH.
However, you can tunnel UDP over SSH, and thus tunnel SNMP traffic.
One possibility is to tunnel using socat.
See e.g.
http://www.derkeiler.com/Newsgroups/comp.security.ssh/2007-01/msg00136.html
for an explanation.
You could probably also configure SNMP to run over TCP instead of UDP, which makes tunneling easier.