_known_hosts(): use files from UserKnownHostsFile options in

addition to standard ones.
This commit is contained in:
David Paleino 2008-06-23 11:28:11 +02:00
parent dae08c0a52
commit 461df636e6
2 changed files with 26 additions and 28 deletions

View File

@ -2510,33 +2510,29 @@ _known_hosts()
user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
fi
# choose which global known hosts file to use
if [ -r "$global_kh" ]; then
kh=( "$global_kh" )
else
[ -r /etc/ssh/ssh_known_hosts ] &&
kh=( "${kh[@]}" "/etc/ssh/ssh_known_hosts" )
[ -r /etc/ssh/ssh_known_hosts2 ] &&
kh=( "${kh[@]}" "/etc/ssh/ssh_known_hosts2" )
[ -r /etc/known_hosts ] &&
kh=( "${kh[@]}" "/etc/known_hosts" )
[ -r /etc/known_hosts2 ] &&
kh=( "${kh[@]}" "/etc/known_hosts2" )
[ -d /etc/ssh2/knownhosts ] &&
khd=( "${khd[@]}" "/etc/ssh2/knownhosts/*pub" )
fi
# Global known_hosts files
[ -r "$global_kh" ] &&
kh=( "${kh[@]}" "$global_kh" )
[ -r /etc/ssh/ssh_known_hosts ] &&
kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
[ -r /etc/ssh/ssh_known_hosts2 ] &&
kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
[ -r /etc/known_hosts ] &&
kh=( "${kh[@]}" /etc/known_hosts )
[ -r /etc/known_hosts2 ] &&
kh=( "${kh[@]}" /etc/known_hosts2 )
[ -d /etc/ssh2/knownhosts ] &&
khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
# choose which user known hosts file to use
if [ -r "$user_kh" ]; then
kh=( ${kh[@]} "$user_kh" )
else
[ -r "${HOME}/.ssh/known_hosts" ] &&
kh=( "${kh[@]}" "${HOME}/.ssh/known_hosts" )
[ -r "${HOME}/.ssh/known_hosts2" ] &&
kh=( "${kh[@]}" "${HOME}/.ssh/known_hosts2" )
[ -d "${HOME}/.ssh2/hostkeys" ] &&
khd=( "${khd[@]}" "${HOME}/.ssh2/hostkeys/*pub" )
fi
# User known_hosts files
[ -r "$user_kh" ] &&
kh=( "${kh[@]}" "$user_kh" )
[ -r ~/.ssh/known_hosts" ] &&
kh=( "${kh[@]}" ~/.ssh/known_hosts )
[ -r ~/.ssh/known_hosts2 ] &&
kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
[ -d ~/.ssh2/hostkeys ] &&
khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
# If we have known_hosts files to use
if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
@ -2583,7 +2579,7 @@ _known_hosts()
fi
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']*\([^*?]*\)$/\2/p' "${config[@]}" )
local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $ocur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
fi

4
debian/changelog vendored
View File

@ -6,8 +6,10 @@ bash-completion (20080617.4) UNRELEASED; urgency=low
- refactored _filedir using quote_readline()
- fixed COMPREPLY's in _iwconfig
- fixed _cvs()
- _known_hosts(): use files from UserKnownHostsFile options in
addition to standard ones.
-- David Paleino <d.paleino@gmail.com> Mon, 23 Jun 2008 11:17:54 +0200
-- David Paleino <d.paleino@gmail.com> Mon, 23 Jun 2008 11:26:28 +0200
bash-completion (20080617.3) unstable; urgency=low