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
Related
im a Student worker for a automobile r&d Company. Im currently working on a Java application that is workling like QXDM but also offers additional Features. I'm stuck with the communication over the DM (Diagnostic mode) port. I tried to use PuTTy for that. Putty and also my application were able to connect to that Port. Now since I got the official dmss documentation, im still not able to get a reply on that port. Do you guys have had the same Problem or at least a similar one and may provide me some help finding the issue? To Switch the phone in diagnostic mode there is a AT-Command. But even though if I connect via puTTy and write down the command, I dont get a reply in putty neither the following diagnostic requests will work.
Does anyone know how to use puTTy to give AT Commands?
The Qualcomm device is connected via USB Dongle using Telit Drivers. Using Telit Serial Diagnostics Interface COM Port.
Using QXDM everything is working fine.
At the moment i have an android client app which connects to my java server through socket - serversocket. It sends and receive strings. The java server is connected to a mysql database (actually mariadb) using the jdbc driver.
I succeed to create a jbossas application and upload the code of the java server to openshift, but i didn't find any detailed tutorial on how do i connect to this new uploaded server from my socket client (This one (RMI or socket connection to Java Program on OpenShift) gives some tips but i'm still stucked).
More on this, how do i know that my server runs just fine on openshift and how do i control de calls to the database after i connect it (found this: $ rhc app create MyApp jbossas-7
$ rhc cartridge add mysql-5.5 -a MyApp), using org.mariadb.jdbc.Driver and java.sql is still working ?
Any small guide or tip is highly appreciated. I'm new to these things so please don't be too heavy on comments.
You can only make connections to your OpenShift server on http/https or ws/wss ports. If you want to connect to your java application and pull data from it from an android device, I would suggest using a RESTful api or a servlet, etc.
I had similar problem: My app server originally was running as a ServerSocket listener, and any clients/devices connect to it directly via Socket binding.
To deploy it into OpenShift, my previous initial solution was to change its host:port configuration by following the suggestion as described in this link [Socket connection to Java Program on OpenShift]. It worked nice as far as my app server was successfully up and running. But it did not work well with the port forwarding approach in order to accept remote requests.
So for the final solution, I modified the app server by wrapping my original code with a RESTful webservice around it, and deploy it as a web service.
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.
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 am using the Apache commons-net lib to telnet into a PC.
After I am done connecting to this server, I want to be able to execute commands on it(server).
What is the best way to achieve this in Java?
You're better off using JSch to telnet to your remote machine and execute the commands. Checkout the examples sections - it has everything you need.