For remote connection: ssh -Y remoteuser@remoteip
I need to open terminal in remote machine only; for example a gnome-terminal.
For remote connection: ssh -Y remoteuser@remoteip
I need to open terminal in remote machine only; for example a gnome-terminal.
This is a typical use case for a library such as 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.
Beyond that: please understand that not every language is suited for all kinds of problems - personal opinion here: I would rather avoid using Java for tasks such as "controlling a remote system" somehow. First of all; I would avoid re-inventing the wheel; you really want to rely on existing solutions. But instead of programming something in Java, I would rather look to other solutions, such as scripting with python; or using tools such as salt, puppet, chef, ...