Web lists-archives.com

Re: ssh config "Include" and bash completion




Hello Hector,

It work for me:

$ grep "Include\|testing" /etc/ssh/ssh_config ; cat /etc/ssh/ssh.d/test
Include /etc/ssh/ssh.d/test
Host testing
Hostname 1.1.1.1

$ ssh test<TAB> => testing
$ dpkg -l bash-completion
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)
| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo
|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)
||/ Nombre                          Versión              Arquitectura
       Descripción
+++-===============================-====================-====================-====================================================================
ii  bash-completion                 1:2.8-1              all
       programmable completion for the bash shell

At bash_completioni script:

$ grep Inclu /usr/share/bash-completion/bash_completion -A10
# This function look for the "Include" keyword in ssh config files and include
# them recursively adding each result to the config variable
_included_ssh_config_files()
{
    [[ $# -lt 1 ]] && echo "error: $FUNCNAME: missing mandatory argument CONFIG"
    local configfile i f
    configfile=$1
    local included=$( command sed -ne
's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p'
"${configfile}" )
    for i in ${included[@]}; do
        # Check the origin of $configfile to complete relative
included paths on included
        # files according to ssh_config(5):
--
                # The Included file is processed to look for Included
files in itself
                _included_ssh_config_files $f
            fi
        done
    done
} # _included_ssh_config_files()


Regards

On Mon, May 14, 2018 at 11:32 AM, Richard Hector <richard@xxxxxxxxxxxxx> wrote:
> On 14/05/18 20:49, john doe wrote:
>> On 5/14/2018 8:09 AM, Richard Hector wrote:
>>> Hi all,
>>>
>>> I recently started using the Include directive in my .ssh/config file -
>>> so all the definitions are now in .ssh/config.d/.
>>>
>>> Now bash completion of hostnames no longer works. Is this expected
>>> behaviour? Anyone know how to fix it, without reverting to a single file?
>>>
>>
>> The only work around I can think of is:
>>
>> $ cat ~/.ssh/config
>> host x
>> include ~/.config.d/x
>>
>> $ cat ~/.ssh/config.d/x
>> hostname x.example.com
>>
>
> Meaning all my hosts need to be specified in both places? Not really
> convenient.
>
> I don't actually use one file per host; I use one per 'group' -
> generally a client, or perhaps a vm or container host.
>
> I assume there's a way to modify the bash completion config, but I
> haven't looked at that. (Now I have, and it's ... going to require
> further study.)
>
> Richard
>