def deploy():
    with settings(host_string='Remote', user='ubuntu', key_filename=
        '/home/ubuntu/key.pem'):
        put('/home/localuser/sample.sh', '/home/ubuntu/')
run('bash /home/ubuntu/sample.sh')
Running Fabric with Python script together