def run(command, shell=True, pty=True):
    """
    Helper function.
    Runs a command with SSH agent forwarding enabled.
    Note:: Fabric (and paramiko) can't forward your SSH agent. 
    This helper uses your system's ssh to do so.
    """
real_command = command
if shell:
    cwd = env.get('cwd', '')
if cwd:
    cwd = 'cd %s && ' % _shell_escape(cwd)
real_command = '%s "%s"' % (env.shell, _shell_escape(cwd + real_command))
if output.debug:
    print('[%s] run: %s' % (env.host_string, real_command))
elif output.running:
    print('[%s] run: %s' % (env.host_string, command))
local("ssh -A %s '%s'" % (env.host_string, real_command))
Run ssh-add with Fabric in a machine