[Bug 2739] New: ssh-add no longer works with xargs

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Fri Jul 7 02:58:04 AEST 2017


https://bugzilla.mindrot.org/show_bug.cgi?id=2739

            Bug ID: 2739
           Summary: ssh-add no longer works with xargs
           Product: Portable OpenSSH
           Version: 7.4p1
          Hardware: amd64
                OS: Mac OS X
            Status: NEW
          Severity: minor
          Priority: P5
         Component: ssh-add
          Assignee: unassigned-bugs at mindrot.org
          Reporter: micahculpepper at gmail.com

I have a small script in my bash profile to ensure my ssh keys have
been added to ssh-add. A recent update broke this.

Here is the command I was using:
find ~/.ssh | egrep 'id_rsa$' | xargs ssh-add -K

Here is the output of everything up until ssh-add:
bash-3.2$ find ~/.ssh | egrep 'id_rsa$' | xargs
/Users/user/.ssh/foo_id_rsa /Users/user/.ssh/id_rsa
/Users/user/.ssh/bar_id_rsa

And that is the expected output.

When I run the whole line, here is what I get today, with error
messages:
bash-3.2$ find ~/.ssh | egrep 'id_rsa$' | xargs ssh-add -K
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or
directory
Identity added: /Users/user/.ssh/id_rsa (/Users/user/.ssh/id_rsa)
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or
directory

The middle key isn't passphrase-protected, and it is added
successfully. The other keys aren't added, and apparently ssh-add can't
find "/usr/X11R6/bin/ssh-askpass". I checked, and sure enough, that
file does not exist.

What's weird is that this works if I don't use xargs. I can do exactly
the same thing in a for loop, and it works:
bash-3.2$ for i in $(find ~/.ssh | egrep 'id_rsa$'); do ssh-add -K $i;
done
Enter passphrase for /Users/user/.ssh/foo_id_rsa:
Identity added: /Users/user/.ssh/foo_id_rsa
(/Users/user/.ssh/foo_id_rsa)
Identity added: /Users/user/.ssh/id_rsa (/Users/user/.ssh/id_rsa)
Enter passphrase for /Users/user/.ssh/bar_id_rsa:
Identity added: /Users/user/.ssh/bar_id_rsa
(/Users/user/.ssh/bar_id_rsa)


The xargs approach was working before. And in fact, I can even do it
all on one line and it works:
ssh-add -K /Users/user/.ssh/foo_id_rsa /Users/user/.ssh/id_rsa
/Users/user/.ssh/bar_id_rsa
Enter passphrase for /Users/user/.ssh/foo_id_rsa:
Identity added: /Users/user/.ssh/foo_id_rsa
(/Users/user/.ssh/foo_id_rsa)
Identity added: /Users/user/.ssh/id_rsa (/Users/user/.ssh/id_rsa)
Enter passphrase for /Users/user/.ssh/bar_id_rsa:
Identity added: /Users/user/.ssh/bar_id_rsa
(/Users/user/.ssh/bar_id_rsa)

I also tried the simple case, in an attempt to rule out find or egrep
as the culprit:
bash-3.2$ echo '/Users/user/.ssh/bar_id_rsa' | xargs ssh-add -K
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or
directory


So:
 - One filename at a time works.
 - Multiple filename arguments works.
 - Filenames coming from xargs does not work.


bash-3.2$ uname -a
Darwin hostname 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14
16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

bash-3.2$ ssh -V
OpenSSH_7.4p1, LibreSSL 2.5.0

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list