DevOps Bootcamp · Lesson

SSH Pipelining & Connection Reuse

Cut overhead per task.

Lesson 3 of 413 steps

SSH Pipelining & Connection Reuse is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

SSH Overhead Adds Up

Every task can mean a fresh login, file copy and execution over SSH. Multiply that by many tasks and many hosts and the overhead dominates the run.

How a Task Normally Runs

By default Ansible copies a module to the host, runs it, then cleans up. Each step costs an SSH round trip you can often avoid.

Pipelining to the Rescue

With pipelining, Ansible streams the module over the existing SSH session instead of writing a temp file first, cutting connections per task.

[ssh_connection]
pipelining = True

The requiretty Catch

Pipelining needs sudo without a TTY, so the remote sudoers must not force requiretty. Modern distros are fine; some hardened ones need a tweak.

Reuse the Connection

OpenSSH ControlPersist keeps a master connection open and routes later tasks through it, skipping a brand new handshake each time.

Tune ssh_args

Ansible enables connection reuse through ssh_args. The ControlPersist value sets how long the shared socket stays alive after the last task.

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s

Where Sockets Live

The shared connection lives in a control path socket file. Keep this path short to dodge the operating system limit on socket name length.

[ssh_connection]
control_path = %(directory)s/%%h-%%p-%%r

Pipelining vs Reuse

They solve different costs: pipelining trims round trips inside one task, while ControlPersist reuses the SSH session across many tasks.

Use Both Together

Pipelining and persistent connections stack. Turning on both is one of the biggest, lowest-risk speedups you can give a large playbook.

Faster Facts Too

If you do not need facts, set gather_facts: false to skip the setup module. That removes an expensive step from every play's start.

Measure the Win

Enable the profile_tasks callback to time each task. It shows exactly where seconds go so you can confirm your tuning actually helped.

Quick Check

You want each task to avoid writing a temp file before running over SSH.

Recap

Turn on pipelining to trim round trips and ControlPersist to reuse SSH sessions. Together they slash connection overhead on big plays. ⚡

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “SSH Pipelining & Connection Reuse” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “SSH Pipelining & Connection Reuse”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “SSH Pipelining & Connection Reuse”?

Cut overhead per task. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.

How long does the “SSH Pipelining & Connection Reuse” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. forks & Parallelism Tuning
  2. Strategies: linear, free & host_pinned
  3. SSH Pipelining & Connection Reuse
  4. serial & Rolling Batch Execution
← Back to DevOps Bootcamp