ccontavalli/ssh-ident

Docs for scp usage seem incomplete

johnemb opened this issue · 1 comments

The documentation (README) for scp usage seems to be lacking something.
In my environment, if I follow option 1) to make scp work with ssh-ident:

  1. Rename 'ssh-ident' to 'ssh' or create a symlink 'ssh' pointing to
    ssh-ident in a directory in your PATH before /usr/bin or /bin
    ...
    If you want to use ssh-ident with scp or sftp, you can simply create
    symlinks for them as well:

    ln -s /path/to/ssh-ident ~/bin/scp
    ln -s /path/to/ssh-ident ~/bin/sftp
    

Then I get:

$ scp otherhost:mydir/file.test .
ssh-ident found 'scp' as the next command to run.
Based on argv[0] (/home/someuser/bin/scp), it seems like this will create a
loop.

Please use BINARY_SSH, BINARY_DIR, or change the way
ssh-ident is invoked (eg, a different argv[0]) to make
it work correctly.

OK. Let's investigate the options.

BINARY_SSH has to be set to the binary (e.g. ssh or scp) to be used for the command in question, so it cannot be fixed ahead of time. One could use an alias, but then we are into documented option 2), which has its drawbacks.

BINARY_DIR, what is that? Well, it is not documented.
It turns out that setting it to the location of scp, e.g. /usr/bin, makes the symlink solution work.

3267764 seems to explain quite a bit of it, but I am not sure about one thing:

Is option 1) mentioned above (using symlinks for scp, sftp) supposed to work without setting BINARY_DIR? If so, under which circumstances?
Or, is BINARY_DIR a prerequisite for using scp, sftp with symlinks, given no other solutions?

Typically this is a problem in the setup, either environment or using multiple ssh-ident symlinks for an binary.

  • Check that there are no duplicate dirs in your ${PATH}, e.g. twice the $[HOME}/bin.
    • Note that duplicates can also occur through symlinks as a different dir/path.
  • Check that there is only one ssh-ident symlink in your ${PATH}, e.g. avoid symlink duplicates like ${HOME}/bin/scp and /usr/local/bin/scp
  • When using symlinks for a binary, then do not use shell alias - and vice-versa
    • The approach can be different per binary
  • BINARY_DIR is a hard-coded workaround, should not be necessary when setup is clean