Fabric is a high level Python (2.7, 3.4+) library designed to execute shell commands remotely over SSH

In the simple explanation is we can execute some command into the remote VPS/Droplet/Machine using python script over SSH. Fabric builds on top of Invoke (subprocess command execution and command-line features) and Paramiko (SSH protocol implementation), extending their APIs to complement one another and provide additional functionality.

When We Use Fabric?

This is only a sample use case. Imagine we have two VPS. Which one is a test server, and another one is a production server. Whenever we push our code into git, the test server will be hooked to execute a test script that will test our code, run a linter, and another you want. After the test script is passed then run a remote script to execute the production script in the production server. To execute the production script, we need Fabric.

How To Get Started

Before we start to try fabric, we need to install the Fabric module first. Pip is a great python package. You can use pip to install packages from the Python Package Index and other indexes.

#python #deployment #devops #fabric #ssh

Execute Remote Command Over SSH Using Python Fabric
2.40 GEEK