Using put operation

The syntax for the Fabric put operation is as follows:

put(local_path, remote_path, use_sudo=False, mirror_local_mode=False, mode=None)

This operation will upload the file from the machine running the fabfile (local) to the remote host. Using use_sudo will solve the permissions issue when you upload to the root directory. Also, you can keep the current file permissions on both the local and remote server, or you can set new permissions:

def put_ops():    try:        put("/root/VeryImportantFile.txt","/root/")    except:        pass

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.