Another question about this shell magic...

Damien Miller djm at mindrot.org
Fri Oct 2 12:46:25 AEST 2020


On Thu, 1 Oct 2020, Ingo Schwarze wrote:

> Hi Martin,
>
> Martin Drescher wrote on Thu, Oct 01, 2020 at 02:06:22PM +0200:
>
> > Can someone tell how this magic works?
>
> No, and this question is off-topic on this list because it is not
> related to OpenSSH.

It's most definitely related to OpenSSH, specifically how the shell
interacts with it.

In answer to the question: many operating system distributions
(especially Linux) have configured their shells with tab-completion
helpers that are contextually invoked by the shell after specific
commands. Another example of this might be "git <tab>" returning a list
of git subcommands.

In this case, the helper is probably looking at the contents of your
~/.ssh/known_hosts or, with less likelihood, ~/.ssh/config's Host/Match
configuration. I don't mind these, though they can be pretty brittle in
the face of ssh_config aliases and HashKnownHosts settings, etc.

Some shell configurations go further and will configure tab-expansion
helpers for things like scp remote paths, e.g. "scp host:foo<tab>" will
actually ssh to the remote host, run "ls foo*" and use the result to
offer a set of completions.

I don't like these because they implicitly perform heavy-weight
operations (establishing a connection to a remote host) without the
user really knowing what's going on. Note that, depending on your
configuration, establishing such a connection can have significant
security consequences - e.g. consider agent-forwarding.

Anyway, check your shell configuration. On many Linux distributions, you
might want to start with /etc/bash_completion*

-d


More information about the openssh-unix-dev mailing list