-1

Newbie here.

I'm working on a windows app in C#(using WPF) that is able to start programs with different settings, stop or restart them, etc.. My question is if there is a way to implement into the same program, to control my linux server. What i would like to achive is an app that let's the user easily control the running services on both computers.

What i was thinking is sending predefined commands directily from the app but i'm not sure if that is possible. Or is there a better way?

Belzeboss
  • 3
  • 2
  • Alternative to what was suggested below is to log in to remote server via SSH (can be done from .NET code) and execute commands as usual, without writing any custom applications. – Evk Jun 18 '17 at 15:30

2 Answers2

0

You can write a service program running on linux, and then use wpf call it.Or you can try ssh, use wpf remote login to linux?

Visitant
  • 1
  • 2
0

You can develop a .NET Core or Mono application that will run on a Linux server as a service. You will communicate with this service using Web API or any other communication protocol out there (messaging, for example).

The service will be able to stop and start services by issuing something like service myservice start but you need to check if this plays well with user permissions.

Running bash commands from a .NET application on Linux is described here: How to start a service in C# on Linux

Remember not to expose a generic "command runner" via the API since you will risk someone taking control of your server. Use proper encapsulation and only expose methods you need. Protect your API properly to avoid being hacked, also inside your private network - there is always a risk.

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83