diff --git a/bash_completion b/bash_completion index ba3b85ae668..c49036244a9 100644 --- a/bash_completion +++ b/bash_completion @@ -1905,7 +1905,7 @@ _included_ssh_config_files() _comp_expand_glob files '$i' if ((${#files[@]})); then for f in "${files[@]}"; do - if [[ -r $f ]]; then + if [[ -r $f && ! -d $f ]]; then config+=("$f") # The Included file is processed to look for Included files in itself _included_ssh_config_files $f @@ -1973,10 +1973,10 @@ _known_hosts_real() # ssh config files if [[ -v configfile ]]; then - [[ -r $configfile ]] && config+=("$configfile") + [[ -r $configfile && ! -d $configfile ]] && config+=("$configfile") else for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do - [[ -r $i ]] && config+=("$i") + [[ -r $i && ! -d $i ]] && config+=("$i") done fi @@ -2023,7 +2023,7 @@ _known_hosts_real() for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \ ~/.ssh/known_hosts2; do - [[ -r $i ]] && kh+=("$i") + [[ -r $i && ! -d $i ]] && kh+=("$i") done for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do [[ -d $i ]] && khd+=("$i"/*pub) diff --git a/test/fixtures/_known_hosts_real/config_include b/test/fixtures/_known_hosts_real/config_include index a1ae76331b4..d54f3ee56bf 100644 --- a/test/fixtures/_known_hosts_real/config_include +++ b/test/fixtures/_known_hosts_real/config_include @@ -5,3 +5,5 @@ Include ~/config_full_path Include config_relative_path # Include with wildcards, and more than one on same row Include config_asterisk* config_?uestion_mark +# Include a directory name. This is a misconfiguration, but ssh ignores it without errors. +Include ../../_known_hosts_real