Jump to content
DarrenWhite99

ConnectWise Automate (LabTech) Agent Push - Install to Linux and OSX using SSH

Recommended Posts

I am attaching two scripts, designed to deploy ConnectWise Automate agents on Linux and OSX using SSH. You must provide the device IP and a valid username/password. The scripts use the internal variable "%redirhostname%" to identify your CWAutomate server. If this value is incorrect you must replace it where it appears in the scripts. (Line 3 in both scripts)

 

The Linux installer tests for the unzip utility, and automatically runs apt-get to try and install the unzip package if needed.

 

There are other (better) LabTech agent deployment tools, but I thought a script based way to install might be helpful as another method to get the job done.

 

UPDATE - Labtech 11 Patch 13 has broken the standard download URL's that this script had relied on. Scripts have been updated to use modified download links.

 

20170918 - For Linux - Edit line 50 and change the size parameter from +1500000c to +1000000c - The attached .zip has not been updated yet.

20170808 - Fix in OSX script for bad URL. Added support to test downloaded file size to catch partial downloads. Updated naming/reference from LabTech to ConnectWise Automate. Thank You to @Basselope/Basse for help testing the script updates.

20170621 - Updated to support download of installer for Location #1. Additional steps to reset the LOCATION_ID in the bundles prior to installation so that the agent is registered correctly.

 

Last update - 20170808 @ 02:00AM PST.

Install ConnectWise Automate Agent over SSH.zip

Edited by Guest

Share this post


Link to post
Share on other sites

The functions used are listed as supported by Windows, OSX and Linux agents. So any agent should be able to push the installation to another machine on the network.

 

VirtualFunctions_AgentOSCompatability.png.e9583f92266553e5062f1727c6588739.png

Share this post


Link to post
Share on other sites

I'm having a small problem with the Mac script. In step 33, it is downloading the zip file, but it is not unzipping it. I have run the command manually on the system and it deletes the old if it is there, downloads the zip file, and unpacks it. However, it just clears out the old and downloads the zip file without unpacking it. Any suggestions? FYI, I figured this out by using the debugger and that was a specific point I was waiting on, because I never saw a new Labtech directory formed.

 

Thanks for the help.

Share this post


Link to post
Share on other sites

Step 33 in my copy says:

cd ~@PushUsername@/Downloads&&(rm -f labtech.zip; rm -Rf LabTech)&>/dev/null; curl '@LTURL@' -s -o labtech.zip;[ -f labtech.zip ]||echo ERROR-Failed to download;[ -f labtech.zip ]&&unzip -n -d LabTech labtech.zip &>/dev/null||echo ERROR-Failed to extract;[ -f LabTech/config.sh ]&&echo SUCCESS-Ready to Install

So, breaking it down:

cd ~@PushUsername@/Downloads <- Change to the home folder for user @PushUsername@/Downloads

&& <- Then, if success

(rm -f labtech.zip; rm -Rf LabTech)&>/dev/null; <- Remove labtech.zip and the LabTech folder, redirecting all output to /dev/null

curl '@LTURL@' -s -o labtech.zip; <- Download labtech.zip

[ -f labtech.zip ] <- Test if file labtech.zip exists in the current folder

|| <- Then, if fail

echo ERROR-Failed to download; <- Report the failure to download.

[ -f labtech.zip ] <- Test if file labtech.zip exists in the current folder

&& <- Then, if success

unzip -n -d LabTech labtech.zip &>/dev/null <- Unzip labtech.zip into a directory named LabTech, redirecting all output to /dev/null

|| <- Then, if fail

echo ERROR-Failed to extract; <- Report the failure to extract.

[ -f LabTech/config.sh ] <- Check if the file LabTech/config.sh exists below the current folder.

&& <- Then, if success

echo SUCCESS-Ready to Install <- Report successful extraction.

 

Does the command just timeout? What is being returned? If nothing, then perhaps one of the steps if halting, waiting for input. Try running "unzip -n -d LabTech labtech.zip" and see what happens. I am hiding all output from that command, so if it threw an error you would not see it. BUT if it threw an error, it is supposed to output "ERROR-Failed to extract". I don't know why it would not unzip for you, but if you run that unzip command manually, you should get an answer.

Share this post


Link to post
Share on other sites

So, I pulled the command out of Automate and manually ran it on the Mac. I swapped out the variables with relevant static values and ran it on the system and it worked just fine. There seems to be an issue with the way it is executing from the script. The file downloads, but does not extract when run from the script. That's what I was able to tell when using the debugger. Line 33 executes and all it does is download labtech.zip, but does not extract the files.

Share this post


Link to post
Share on other sites

What is the value in %sshresult% after step 33?

What happens if you break it into two steps?

Copy lines 33-35 together, and paste them in again so that you have steps 33-35 repeated in steps 36-38, the current step 36 would now be 39. Change lines 33 and 36 to the following:

33 - cd ~@PushUsername@/Downloads&&(rm -f labtech.zip; rm -Rf LabTech)&>/dev/null; curl '@LTURL@' -s -o labtech.zip;[ -f labtech.zip ]||echo ERROR-Failed to download
36 - cd ~@PushUsername@/Downloads||echo Error changing directories;[ -f labtech.zip ]&&unzip -n -d LabTech labtech.zip||echo ERROR-Failed to extract;[ -f LabTech/config.sh ]&&echo SUCCESS-Ready to Install

 

I removed the '&>/dev/null' from after the unzip statement, so any error output should hopefully be seen in the output stored in %sshresult%. (As long as the word SUCCESS does not appear in %sshresult%, it will jump to the ':FAILURE' label and the result returned will be logged there..

 

When you run it manually, are the files extracted to ' ~@PushUsername@/Downloads', or ' ~@PushUsername@/Downloads/LabTech'?

Share this post


Link to post
Share on other sites

I'll have to check all the other stuff later, but when I ran it manually, it extracted it to ~@PushUsername@/Downloads/LabTech'

Share this post


Link to post
Share on other sites

I made the change to the script and here is the result of %sshresult% I get after step 33.

 

cd ~proadmin/Downloads&&(rm -f labtech.zi 
p; rm -Rf LabTech)&>/dev/null; curl 'http://prosum.hostedrmm.com/Labtech/Labtech 
/Deployment.aspx?InstallType=mac' -s -o labtech.zip;[ -f labtech.zip ]||echo ERR 
OR-Failed to download

 

And yes, there are weird spaces in there that aren't in the actual command. I'm not sure what the deal is with that.

Share this post


Link to post
Share on other sites

I see a lot of people trying to use this command to ssh and install xPulse for mac and linux.

I was wondering if anyone successfully used these to install the agent on a Windows machine?

Currently on Patch 15

What I have already tried:

So far tried this on a linux machine, and a Windows machine.

Script is always failing on step

"Confirming login and changing path to /tmp.

tested login on Linux machine and successfully logged in with credentials.

on the script where it asks for the username and password, using

 

domain\ admin user

password

 

any help would be greatly appreciated

 

Thanks

Share this post


Link to post
Share on other sites

The scripts should run ON any agent, with any OS. You must provide the name or IP address of the computer that you want to install the CWA agent on, along with valid login credentials. The agent running the script will be used to establish an SSH session with the target, then login, and install.

 

The steps for each target OS are similar, but distinctly different, that is why there are two types of scripts. These scripts cannot install the Windows agent on the new machine, because even if the commands they sent worked on Windows, you can't connect to Windows using SSH.

 

Is there something that I am missing or didn't understand from your question? Or did my answer clear it up for you?

Share this post


Link to post
Share on other sites

Hi Darren

 

Nope that answered my question. The reason I was trying this on Windows was because of your post:

 

"The functions used are listed as supported by Windows, OSX and Linux agents. So any agent should be able to push the installation to another machine on the network."

 

Made it seem like this would work in a Windows environment.

 

Thanks for responding.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...