Stop logging in to twenty boxes just to check a single file

SSH & Remote Administration

Stop logging in to twenty boxes just to check a single file

🧩 The Challenge

You’ve got a config change to verify across a whole cluster of web servers, but logging into each one individually is a soul-crushing exercise in redundancy. I’ve wasted way too many Saturday afternoons doing exactly that while the coffee went cold.

💡 The Fix

Use SSH’s built-in support for executing commands across multiple hosts at once without needing a full-blown configuration management tool. It’s perfect for quick spot checks when you don’t want to spin up Ansible.

ssh -o BatchMode=yes -o ConnectTimeout=5 user@host1 'grep "Listen" /etc/nginx/nginx.conf' && ssh -o BatchMode=yes -o ConnectTimeout=5 user@host2 'grep "Listen" /etc/nginx/nginx.conf'

⚙️ Why It Works

Passing the command as a quoted argument tells the remote shell to run that specific binary and return the output directly to your terminal. It skips the interactive TTY overhead entirely, which makes the whole thing feel instant.

🚀 Pro-Tip: Put your host list into a shell loop and save yourself the carpal tunnel.

Linux Tips & Tricks | © ngelinux.com | 10/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted