January 2019
Beginner
318 pages
8h 23m
English
Fabric is a Python library as well as a command-line tool for the use of SSH. It is used for system administration and application deployment over the network. We can also execute shell commands over SSH.
To use fabric module, first you have to install it using the following command:
$ pip3 install fabric3
Now, we will see an example. Create a fabfile.py script and write the following content in it:
from fabric.api import *env.hosts=["host_name@host_ip"]env.password='your password'def dir(): run('mkdir fabric') print('Directory named fabric has been created on your host network')def diskspace(): run('df')
Run the script and you will get the output as follows:
student@ubuntu:~$ fab dirOutput:[student@192.168.0.106] ...
Read now
Unlock full access