There is no clear answer and there is a reason for it. The answer
depends on the application's requirements. You have two possible solutions
which have their pros and cons.
Creating a service means that you follow a Service Oriented Architecture. This would be a good
choice if your service is going to be used by many clients and you want it
to be client agnostic. This is an overkill if you have only one specific
If you have one specific client which is written to communicate with
the specific server you could always use the direct ssh solution. Perhaps a
library like Java
Secure Channel would the most straight forward solution.
A third option would be to use something like RMI (Remote Method Invocation). This is a more complicated
solution and I would not suggest it because in my opinion it has no
Hope I helped!