DevOps & Cloud

fabric

Type a command once and Fabric quietly runs it on every server on your list, like a group text for computers.

Install it: pip install fabric

What does it do?

Fabric lets a Python script log into remote computers over SSH, the same secure connection method IT professionals use, and run commands as if it were sitting at each keyboard. It’s built on top of a lower-level library called Paramiko but wraps it in a much friendlier interface: instead of writing pages of connection-handling code, you write something close to run this command on these ten servers and Fabric handles the rest. It’s especially popular for deployment scripts — pulling new code, restarting a service, and checking it came back up.

See it in action

This connects to a remote server over a secure connection, runs a command to check what operating system it’s using, and copies a file up to it.

from fabric import Connection

c = Connection("user@your-server.com")
result = c.run("uname -s", hide=True)
print(result.stdout.strip())

c.put("local_file.txt", remote="/tmp/local_file.txt")

Why would a non-developer care?

Somewhere behind almost every website’s we-just-pushed-an-update moment is a script doing exactly what Fabric automates: connecting to servers and executing the steps needed to go live. It’s the difference between a person manually deploying software by typing the same commands over and over, and a script that does it reliably in seconds.

Real-world examples

Fabric has been a staple of Python deployment workflows for over a decade, often used by small and mid-sized engineering teams who want deployment automation without adopting a heavier configuration management system. A team without something like Fabric ends up with deployment folklore — SSH into the server and run these five commands in this exact order — passed down as tribal knowledge and inevitably broken when someone forgets a step.

Who uses it

Developers and small ops teams who need lightweight, scriptable remote server automation without the overhead of a full configuration management system.

How it compares to alternatives

Ansible covers similar ground but is more focused on declarative configuration management at scale, while Fabric is more like a scripting toolkit for one-off or routine remote commands. Under the hood, Fabric relies on Paramiko to actually speak the SSH protocol.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries