Assuming I define a trivial task to list files on a remote server:
from fabric.api import run, env env.use_ssh_config = True def list_files(): run(\'ls
Answer for fabric 2.4.0 looks like this:
fabric 2.4.0
from fabric import Connection conn = Connection(host=HOST_NAME, user=USER_NAME, connect_kwargs={'password': PASSWORD}) with conn.cd('/tmp/'): conn.run('ls -la')
This is not covered by the fabric documentation but by the invoke documentation.
fabric