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.
Related
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.
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
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.
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
I want to establish a connection with my UNIX file system using java program.. So that I can make some File I/O operations and normally I can connect using Putty.
How can I do the same using java program
I have the Host name, username,password and Port number
Help appreciated :)
You need several things:
A server that takes commands (create directory, list directory, write data to a file, read data from a file) over the network. This server should listen to port1 on localhost
You need to configure putty to forward port2 on your local computer to port1 on the server.
A local client which allows you to connect to port2 on your local computer. Putty will tunnel any data send to port2 to port1 on the remote server and vice versa.
Or you get WinSCP which uses the SSH protocol (just like Putty) and maybe already does what you want.
There's a pure Java implementation of SSH/SCP available: http://www.cleondris.ch/opensource/ssh2/
You can use its SCPClient or SFTPv3Client classes to work on the remote file system.
Documentation is available at http://www.cleondris.ch/opensource/ssh2/javadoc.
If you want to do it from Java, you can use Apache Commons VFS. It provides a common approach to dealing with files on all of the supported file systems. SFTP is one of the supported types which is most likely what you would need if you have been connecting with PuTTY.
You need SSH client. There are various pure java SSH clients. Google "java ssh client" and try any one of them. I used Jsch http://www.jcraft.com/jsch/ and it worked fine for me.