Framework (Java) for Opening remote sessions for executing Unix-based Server commands

Asked

Viewed 161 times

2

I needed a framework to be able to open remote sessions on (Unix-based) servers and run commands remotely (if possible as root even).

Does anyone know any mature who can serve this purpose?

Main objective:

What happens is that I have a web application running on a server and I need to collect data on other servers. This data is pre-processed on a shell script and store the results in a file.

There are more than 10 servers, and it would be excellent/ideal that the execution of this script on each of the servers was made from the application, instead of running it machine by machine and then from the application read the result. The idea is to open a session for each of the machines and run the pre-processing and then read the results.

What I got:

I currently use the jsch 0.1.42 and has given me a serious problem, I cannot run existing scripts on the servers whose some operations involve writing (creating new files) on the system.

Note: My main problem at the moment is that the execution of jsch 0.1.42 does not run successfully, but when I enter directly into the machine it runs perfectly.

As for permissions I have also analyzed and to remove doubts the permissions is everything for everyone(777).

I believe (I hope it is not the result of my despair) that the problem is with the jsch 0.1.42 and would like to change and move on to another, where someone already has some experience.

1 answer

1

I’ve used the jsch to make build and deploy remote. Unfortunately I don’t have the source code because it was in a company where I no longer work.

What I can say is that it works, but it is very complicated. It was a good part of trial and error, some adjustments related to encoding, including modifications to the design source itself.

I don’t recommend this kind of solution.

If you were to implement something like that today, probably:

  1. Make an application simple with a Web Service Rest that listens on a particular port, executes the necessary commands and returns the information.
  2. I would use another language with more modern libraries like Ruby or Pyhton.

If you really need to be an SSH client, you would probably use Python, since there seems to be several implementations of the protocol for this language.

As it was mentioned that the information would be read by an application, it is important to consider issues of timeout and parallelization. The application can use different threads to make a request to the web service (or SSH).

There should be a central control to not make the user wait "always stop" in case of failure and also to ensure that no connections are accumulated blocked by some communication failure (especially in the case of SSH).

  • Because it is @utluiz, the point is that you can not apply the first solution because it is a sensitive server (very sensitive) and the owners will not accept anything there running too much, for sure. The second point is interesting, but I don’t know much of these languages,and even learning and redoing almost everything I’ve ever done would be "dull". I’m considering using Pyhton.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.