How to ForwardAgent yes using fabric?

Question:

I am successfully run()ning commands on remote server with my private key pair.

However, I’d like to do git clone ssh://private/repo on remote server using my local key (or using local ssh agent I’m in).

How to do it using fabric?

Asked By: Almad

||

Answers:

The short answer is that fabric uses a forked version of paramiko and that paramiko doesn’t support ssh agent forwarding.

The long answer is that there are issues for this both for fabric and paramiko. Even there’s a comment in the fabric issue that contains links to a fork of both fabric and the forked paramiko version with ssh forwarding support. Hence, if you want to make use of that feature you’ll need to get the latest version from there or wait for a while until it’s officially released.

Answered By: jcollado

Since version 1.4 fabric has environment option that enables agent forwarding.

env.forward_agent = True

UPD: This feature was buggy before fabric 1.4.2

Answered By: anatoly techtonik