Cheatography
https://cheatography.com
Fabric is a library built on top of Invoke and Paramiko which provide high-level classes and functions for a Python script to execute command remotely via ssh.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Quick Start
import fabric
with fabric.Connection(host="primary") as connection:
# Run and suppress (hide) the output
result = connection.run("whoami", hide=True)
user = result.stdout.strip()
print(f"{user=}")
|
Connection Object Common __init__ Keywords
- host
- user
- port
- config
- gateway
- ssh_config
- connect_timeout
- connect_kwargs
|
Connection Object Common Attributes
- host
- user
- port
- is_connected
- ssh_config
|
Connection Object Common Methods
get(args, *kwargs) # Download
put(args, *kwargs) # Upload
run(command, **kargs) # Run a command, return a result
sftp() # Opens a SFTP connection
sudo(command, **kargs) # Run a command as root
|
|
|
|