How to Run Remote Commands on Linux

Written by Daniel Fay on August 15, 2020

Share This Article

In previous lives as a younger administrator looking to get involved in larger architectural projects and automation, I had to start learning how to run remote commands and write custom cron job scripts. A lot of the processes were manual, but by introducing a few new commands and cadences, I was able to execute a few minor tasks that made a large impact. The power of running Bash commands is alive and well, and you don’t necessarily need a live SSH terminal to do them.

Bourne to Bash

Bash, originally known as “Bourne-again Shell,” was the successor to the Bourne shell from older versions of Unix®. Bash is composed of Bourne capabilities, but with lots of new and useful add-ons that allowed wider and quicker adoption in many *nix distros. When you’re first getting started with learning the shell as a new admin, it can be frustrating but exciting as you build up your skills. Bash scripting custom nightly jobs or writing a command to remotely check the status of multiple services are just two minor but fairly common examples of what’s possible with Bash and remote commands. 

The traditional way to execute commands and Bash scripts was to manually execute them on a physical KVM (Keyboard Video Monitor) or through multiple remote SSH sessions to the target systems. This was time consuming and sometimes a hassle when you needed to run the same command on multiple machines that was super minor and wasn’t a daily cron or scheduled job. Today, there are multiple tools out there that can help admins with their remote commands and scheduled tasks within their Linux environment.

Executing Remote Commands for Linux

Luckily, today, there’s a comprehensive system management tool that admins can implement that covers remote commands, as well as identity and access management (IAM), security policies and more, all from the comfort of their home. JumpCloud’s Directory-as-a-Service® gives admins the ability to integrate their current endpoints and infrastructure into a comprehensive cloud directory, making tasks easier, automated, and secure. 

JumpCloud has device management built into its Directory-as-a-Service, but one of the coolest features is the ability to write custom scripts or commands and execute them on your entire Linux fleet within seconds. This is done via the JumpCloud Agent, which is installed on any macOS®, Linux, or Windows® device — wherever it may be. This lightweight agent allows admins to control policies, user access, system multi-factor authentication (MFA), remote commands, and more.

For example, a nightly job I run all the time on my Linux systems is to pull any new updates or upgrades from the public repo. Of course, you could change this up to pull from a repo that you control or manage, but in our demo lab, this works fine as an example. 

To ensure my Ubuntu®/Debian® servers stay up to date, I run the simple command:

apt-get -y update && apt-get -y upgrade

Within JumpCloud, the command is set to run against all of my Ubuntu- and Debian-based machines at 5 a.m. MT on a nightly scheduled basis. When you create a JumpCloud Command, you can set the exact time that the command should run and whether it’s on a repeating cadence, just once, or via API-webhook. 

screenshot demonstrating JumpCloud command for Linux Debian/Ubuntu distributions

Every morning when I log into my JumpCloud organization, I can easily see the updates and commands results by looking in the “Results” output below the command list. Reviewing a command result, you can see exactly the readout from the shell during execution of the command as well as any errors if there were any to arise. 

screenshot showing result details of remote Linux command

For a list of pre-made commands, check out JumpCloud’s Command Gallery for easy copy-and-paste commands you can start implementing for your Linux systems. 

Create, Customize, & Command Your Fleet

Organizations all have their own unique workflow, regulations, and tasks. JumpCloud’s flexibility and customization abilities are like handing an admin a high-powered multi-tool. Easily automate daily routine tasks carried out on Linux systems by creating a scheduled command. Need to send a payload or a custom file? Add the file as a payload to your remote command and the Linux fleet will receive them in the tmp folder. Want to make API calls to execute commands en-masse instantly? Then leverage JumpCloud Commands and webhook triggers. 

JumpCloud’s Directory-as-a-Service is available to evaluate and test free forever for your first 10 users and 10 systems. By signing up for a free account, you’ll also receive 10 days of premium 24×7 in-app chat support for free for any issues or assistance needed during your evaluation. 

To learn more about how JumpCloud works or to learn more about specific modules, check out JumpCloud University for tailored educational courses on different parts of the platform. Manage your Linux fleet with the JumpCloud agent and remote commands today!

Daniel Fay

Daniel Fay is a Product Marketing Manager at JumpCloud.

Continue Learning with our Newsletter