DEV Community

Cover image for SSH Server Management Without the Ansible Overhead
Scrooge Mcduck
Scrooge Mcduck

Posted on • Originally published at vae-scrooge.github.io

SSH Server Management Without the Ansible Overhead

You SSH into 10 servers to check disk space. You write a quick for loop. A typo crashes one session. You're not sure which ones you've already checked. By the time you're done, 20 minutes are gone and you have a terminal full of scrollback you need to piece together.

There's a better way.

The Problem

Most developers SSH into servers one at a time. When you need to run the same command across multiple machines, your options are:

  1. Open 10 terminals — error-prone, slow, no audit trail
  2. Write a shell loopfor host in web-01 web-02 ...; do ssh $host "df -h"; done — works until a host is down and your loop breaks
  3. Ansible — powerful, but you need to learn YAML DSL, write playbooks, manage inventory files. Overkill for "check disk space"
  4. Fabric — good Python library, but no built-in host management or CLI

None of these give you a simple CLI that just works out of the box.

Meet remote-cmd

remote-cmd is a Python CLI + API for SSH server management. It gives you:

  • Host CRUD with tag-based grouping (production, staging, web, db)
  • One-shot command execution on single or multiple hosts
  • File upload/download via SFTP
  • A Python API for scripting automation
  • Zero setup — pip install and go

Quick Demo

# Install
pip install remote_cmd_manager

# Add your first server
remote-cmd host add web-01 192.168.1.10 ubuntu --key ~/.ssh/id_rsa

# Run a command
remote-cmd run web-01 "uptime"
# → 14:32:10 up 45 days,  2:15,  1 user,  load average: 0.08, 0.03, 0.05

# Add more servers and run across all production hosts
remote-cmd host add web-02 192.168.1.11 ubuntu --key ~/.ssh/id_rsa --tag production
remote-cmd host add db-01 192.168.1.20 ubuntu --key ~/.ssh/id_rsa --tag production --tag database

remote-cmd batch-run -t production "df -h /"
# ✓ web-01  → Disk: 32G/100G (32%)
# ✓ web-02  → Disk: 45G/100G (45%)
# ✓ db-01   → Disk: 12G/50G  (24%)
Enter fullscreen mode Exit fullscreen mode

Real-World Use Cases

Incident Response

# Check errors across all web servers in 3 seconds
remote-cmd batch-run -t web "journalctl -xe -n 50 | grep -i error"
Enter fullscreen mode Exit fullscreen mode

Deploy Code

from remote_cmd.core.host_manager import HostManager

manager = HostManager("hosts.json")
for host in manager.list_hosts(tag="staging"):
    with manager.connect_to_host(host.name) as client:
        client.execute("cd /app && git pull")
        client.execute("pip install -r requirements.txt")
        client.execute_sudo("systemctl restart app", password="sudopass")
Enter fullscreen mode Exit fullscreen mode

Config Update

# Upload new nginx config and reload across all web servers
remote-cmd upload web-01 ./nginx.conf /tmp/nginx.conf
remote-cmd run web-01 "sudo cp /tmp/nginx.conf /etc/nginx/nginx.conf && sudo nginx -t && sudo systemctl reload nginx"
Enter fullscreen mode Exit fullscreen mode

How It Stacks Up

remote-cmd ssh + shell Ansible Fabric
Setup time 10 seconds None (you know ssh) 30 min+ 5 min
Host management Built-in Manual Inventory YAML Manual
CLI Yes Yes ansible cmd fab cmd
Python API Yes No No (YAML) Yes
Ideal for Ad-hoc + scripts One-off Config mgmt Python scripts

Getting Started

pip install remote_cmd_manager

# Full documentation
remote-cmd --help

# GitHub
# https://github.com/Vae-Scrooge/remote-cmd
Enter fullscreen mode Exit fullscreen mode

The project is in beta, the core API is stable, and contributions are welcome.

If you SSH into more than a couple servers regularly, give it a try. It'll save you the "which servers did I check again?" moment.

Top comments (0)