Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.23k stars 568 forks source link

Pass Device Group as install option #1006

Open penguinthingie opened 4 years ago

penguinthingie commented 4 years ago

Hi Guys,

Apologies if this has already been brought up and worked on. Currently, all the Windows/Mac agent installers are specific to which group they are downloaded from. This causes a headache when we have 30-40 different groups and need to create an install packaging for each group. Is it possible to create the installer to be able to take on the device group as an argument to be passed during the install, such as "agent.exe -fullinstall -DG=randomgroup" DG in this case being a placeholder for the argument to pass the actual group name.

This way, we only have 1 installer we can always keep up to date and maintain from enterprise packaging perspective. Please let me know if you need any clarifications on the request.

Thanks for all the great work as always! Cheers!

ryanblenis commented 4 years ago

FYI the way I handle this is to have an "Ungrouped" set that all get deployed to, so I know to move them to the appropriate group, but this would be a good option.

vyacheslav25 commented 4 years ago

You can make a group common, load devices into it, and then transfer it to other groups. Click on the device and select Change Group and select the group to which you want to transfer. I hope I could help you. image

penguinthingie commented 4 years ago

Thanks guys, unfortunately the amount of machines we are talking about to move one by one is over hundreds at a time so looking for the automated way to pass the specific group during the Imaging process to keep it efficient.

ryanblenis commented 4 years ago

You can multi-select them using the list view and move them in bulk with the group action menu instead of one by one.

Screen Shot 2020-03-10 at 7 12 16 PM

I think you can tag the agent via the install parameters or the .msh file. You can then list-view the tags page and move them in groups as well.

krayon007 commented 4 years ago

We almost have this functionality right now... I modified the installer, but I haven't renamed it yet, because we were still doing testing, but with the agent binary, if you use option:

agent.exe -finstall

it behaves similarly to fullinstall, but was rewritten in javascript to be more flexible... Any option you pass with --, will get inserted into the system service manager, and passed as a command line parameter to the actual service. (Works on all platforms, Linux, MacOS, FreeBSD, and Windows)

so for example:

agent.exe -finstall --DG=randomgroup

will cause the service manager to pass --DG=randomgroup to the agent when it starts. You can actually pass any of the msh flags in this fashion...

To support the requested usage, we'd simply have to add support for a DG msh flag.

krayon007 commented 4 years ago

Just for completeness, the updated uninstaller is -funinstall, so if you did:

agent.exe -funinstall

it will do the equivalent of -fulluninstall

For other platforms, you would do: ./meshagent -funinstall

Ylianst commented 4 years ago

Sorry for the delay, lots going on. There is a solution to this you can use right now. When installing an agent, you will see a meshagent.msh file that contains the agent configuration. It looks something like this:

MeshName=Lab Computers
MeshType=2
MeshID=0xEDBE1BE377...
ServerID=D99362D5ED8BA...
MeshServer=wss://xxxxxxxx.com:443/agent.ashx

Note the "MeshID" line is the identifier of the device group the agent should belong to. If you change that line, the agent will be in a different device group.

When you download a meshagent.exe on Windows, this .msh file is added into the executable. However, if you use the generic "meshagent.exe" and place the "meshagent.msh" you want next to it and run the agent, it will use the .msh file next to the agent executable. So...

Go in "node_modules/meshcentral/agents" and get "MeshService-signed.exe". Rename that file to "MeshAgent.exe" and then generate the .msh you want, place it next to the agent executable and run it. You .msh file must have the same name agent the agent executable, but .msh instead of .exe.

It's unlikely we would provide a way to install the agent by selecting a device group by it's name because a device group name is not a unique or trusted identifier for a group. Only the long HEX value is.

Let me know if this helps, Ylian

penguinthingie commented 4 years ago

Hi @Ylianst thanks for the detailed suggestion. Unless i am missing something with your suggestion, I would still need to have different msh files for each different device group i am looking to have the devices to be part of, no?

Currently, the process for install of the agent is the following; I download the specific agent for each device group and then use the specific device group agent to be part of an post-image install script that simply runs the installer with the -fullinstall string.. the install script takes into account which group that laptop is going to be part of and then executes the installer for that group and one of them is the mesh agent thats specific for that group.. what I am hoping we could achieve is instead of having all different specific agents with the MeshID string already embedded into those agents, the ability to pass the MeshID directly during the install process without having to deal with any other additional files or configurations.. it would significantly reduce the duplicate needs for an agent file for each individual groups and provide a much more ease of manageability to keep the agent file up to date..

I realize that each agent always updates the first time they connect to the server, however sometimes some of the machines for our org can be in a really difficult internet challenged locations and the first time updating to the latest can be a bit cumbersome so keeping a more easier to maintain one agent file would be really useful.

The method @krayon007 has mentioned to be able to pass on as a flag would be the most awesome to have and as far as the group needing to be unique such as the long HEX value is still feasible for us as long as we can pass that on during the install process..

Apologies for the long wall of "attempting to articulate" the request.. please let me know if i need to provide additional clarifications.. Thanks!

Ylianst commented 4 years ago

In your case, all the .msh files are probably the same except the "MeshID" line. The "MeshName" and "MeshType" lines don't serve anything really, "MeshName" is used to display the name in the MeshAgent install UI. So, if your installer knows all the MeshID's, it can generate the .msh file on the fly.

This said, if you like to specify the MeshID along with -fullinstall, I think this is very much possible. Bryan would have to look into this.

tradexsrl commented 4 years ago

meshagent.msh

where do i get MeshID and ServerID to build the msh file ?

Ylianst commented 4 years ago

The ServerID is fixed for your server, so you should look at any .msh and just use that one. FOr the MeshID, you can use the "MeshCtrl" tool to list device groups. On the MeshCentral server try:

node node_modules/meshcentral/meshctrl

I will give you a help screen to get started. You can use this tool to perform operations on MeshCentral and list device groups, users, etc.

You can also run node node_modules/meshcentral --showmeshes on the server to get a full dump of all device groups.