Connect the other user through remote machine on local machine? - java

I wanted to connect a Remote machine using java and have to run some commands from cmd prompt. To do this, I need a confirmation the tool (AutoIt) which i picked is working fine for me. Is there any possible to connect two users in our laptop and connect the other user by remote machine.. so that i can verify and proceed..
Any possibility to write a program to ssh to remote machine and execute some commands?

You can use JSCH
JSch is a pure Java implementation of SSH2.
JSch allows you to connect
to an sshd server and use port forwarding, X11 forwarding, file
transfer, etc., and you can integrate its functionality into your own
Java programs

Related

Use ssh key for remote java debugging using intellij

I want to do remote java debugging using Intellij by connecting to a running program on a remote machine.
However, I use an ssh key to access this remote machine and cannot find any place to specify this key in the remote configuration window. Any idea how this can be done? Thanks!
You should first create an ssh tunnel to the remote machine and then connect to the program just as if it was running on your own system.

Java Debugging over 2 machines

I am working in Linux environment where my java process is running on Machine C.
in order to connect to Machine C from my machine A i need to connect through B for security reason and there is no option to connect directly to machine C.
is there any way to debug the java process that running on machine C.?
Thanks in advance
You can set up a tunnel through machine B. You can use ssh tunneling by issuing this command from machineA:
ssh root#machineB -L 5005:machineC:5005
You will need to configure your IDE to debug remotely, pointed at machineA port 5005, and configure the remote JVM on machineC for remote debugging on port 5005, something like this:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Assuming your IDE is running on the same machine as the ssh client, that is, machineA, you can point your IDE to localhost:5005 and the ssh command will attempt to tunnel all connections you make to localhost:5005 through to machineC:5005.

Start a java application from a remote computer using ssh protocol

I want to start my java app remotely. I'd like to use the SSH protocol as a way to communicate. Is there a library that will help do this?
SSH client and server in java
But I would use just ssh support built in the system, so you connect to the box with ssh and then just use terminal to access command-line console of your java app.

Opening Notepad on remote system using RMI

I am trying to use RMI to open notepad in the remote system.
Is it possible to do that using RMI??
Or do I have to use SSH ??
Comparing RMI with SSH is a bit like comparing apples with oranges. RMI is more of a general purpose API for performing requests over the network, while SSH is a program used to establish a secure shell connection over which you can send shell commands.
To open Notepad on a remote host, you can use either RMI or SSH since both are capable of communicating over the network.
In either case, you'll need a server on the receiving end, that handles your commands and opens Notepad for you. If you use SSH, this will be readily available to you, in the form of an sshd daemon. In case you go for RMI I don't know of any predefined server implementation. I would recommend you to write up your own server serving your particular requests.

how to access a remote database in java which can be accessed only through ssh

I need to access the remote MYsql database from java which can be accessed only through ssh
SSH tunneling works perfectly fine for my application as most of the linux systems come with built in ssh client.
java.sql.Connection extension for SSH
what if i need to access the database from windows system, by using putty or some other ssh client.
can we do ssh tunneling in windows system as if in ubuntu systems.:)
Yes, you can, see Using PuTTY under Windows to create an SSH tunnel to your NetManager. Basically you need to set up a tunnel to the mysql port and then you can use the JDBC as natural without it being aware of the tunneling happening
There are plenty of SSH clients for java:
Apache MINA SSH
Java Secure Channel (JSCH)
github.com/shikhar/sshj
http://orion-ssh2.sourceforge.net/
Probably you can take a look and see who is going to work for you, but I think jsch could solve your probelm. See examples here

Categories