question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`transfers.rsync` ignores ssh agent and always asks for key password

See original GitHub issue

Thanks for making patchwork compatible with Python 3! Trying to port one small project to Fabric v2:

from invoke import task
from patchwork.transfers import rsync

def get_proj_path():
    from fabric.main import program
    return program.collection.loaded_from

@task
def upload(c):
    rsync(c, '%s/configs' % get_proj_path(), '/tmp')
> /Users/user/.virtualenvs/test1/lib/python3.6/site-packages/patchwork/transfers.py(131)rsync()
    129     cmd = cmd.format(options, source, user, host, target)
    130     import ipdb; ipdb.set_trace()
--> 131     return c.local(cmd)

Remote command works fine with ssh agent running:

ipdb> print(c.run('pwd'))
/root
Command exited with status 0.
=== stdout ===
/root

(no stderr)

c.local("rsync -pthrvz --rsh='ssh -p 22 ' /Users/user/work/project/configs root@1.2.3.4:/tmp") asks for ssh key:

ipdb> c
Enter passphrase for key '/Users/user/.ssh/id_rsa':

Running the same command from the shell works fine:

% rsync  -pthrvz  --rsh='ssh  -p 22 ' /Users/user/work/project/configs root@1.2.3.4:/tmp
sending an incremental file list

sent 237 bytes  received 18 bytes  72.86 bytes/sec
total size is 10.45K  speedup is 40.99

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
max-arnoldcommented, May 19, 2018

Below is my current workaround for this issue:

def rsync_with_agent(ctx, *args, **kwargs):
    """Ugly workaround for https://github.com/fabric/patchwork/issues/16."""
    ssh_agent = os.environ.get('SSH_AUTH_SOCK', None)
    if ssh_agent:
        ctx.config['run']['env']['SSH_AUTH_SOCK'] = ssh_agent
    return rsync(ctx, *args, **kwargs)
0reactions
krupancommented, Dec 12, 2019

I’m having another problem related to this (problems with local mentioned above), trying to run my django unit tests before deploying:

c.local('poetry run python manage.py test')

Gives me this:

[KeyError]  
'PATH' 

But running remotely with c.run works just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSH ignores key in agent and keeps asking for key decryption ...
I guess SSH identifies the keys available in the agent by their public part - without them it thinks that the key is...
Read more >
How to Setup Rsync without password with SSH on UNIX ...
You can use rsync via ssh without a password by using public key authentication (key pair with no password) and the command option...
Read more >
Passwordless rsync while requiring key and password for all ...
I have a server set up to require public-key authentication for ssh access using a key with a password.
Read more >
How to pass password automatically for rsync SSH command?
the easiest way to pypass password prompt every time you transfer or login your ssh is to create a key, here's how you...
Read more >
[SOLVED] Rsync through ssh with public/private key keeps ...
Set up ssh so you can login with key-based authentication. You do not need a password when this is working. Make sure you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found