zsh-users
 help / color / mirror / code / Atom feed
* An improved "hosts" completion handling
@ 2006-11-08 17:23 Christopher Browne
  2006-11-08 17:32 ` William Scott
  2006-11-08 18:44 ` John Eikenberry
  0 siblings, 2 replies; 3+ messages in thread
From: Christopher Browne @ 2006-11-08 17:23 UTC (permalink / raw)
  To: zsh-users

I had been using some code I'd seen "out there" to pull known_hosts as
a way of setting up a $hosts value so that ssh/telnet could do tab
completion on host names.

I think this was the source, more or less...
http://www.2701.org/archive/200405030000.html

With the changes in openssh, of late, ~/.ssh/known_hosts is now
littered with encoded host names that were getting pulled in such that
I'd get tab completion looking like the following:

cbbrowne@dba2:~/Slony-I/slony1-HEAD-pristine> ssh rg  ssh
rg570-da-logdbs
  Wednesday 17:20:40
rg570-da-logdbs
rg570-da-logdbs1
rg570-da-logdbs1.nj.site\ ssh-rsa\
AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
rg570-da-logdbs2
rg570-da-logdbs2.nj.site\ ssh-rsa\
AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=

Bleah.  That's awful.

The following showed an alternative that does some better parsing, as
well as reading IP addresses.

http://www.zsh.org/mla/workers/2006/msg00280.html

Here's my adaption of this:

for file in $HOME/.ssh/known_hosts /etc/ssh/known_hosts; do
  if [[ -r ${file} ]] ; then
    _cache_hosts+=(${${${(u)${(f)"$(<${file})"}%%[
,|#]*}:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)})
  fi
done
zstyle ':completion:*:hosts' hosts $_cache_hosts

Hope that is of assistance to others...
-- 
http://linuxfinances.info/info/linuxdistributions.html
"...  memory leaks  are  quite acceptable  in  many applications  ..."
(Bjarne Stroustrup, The Design and Evolution of C++, page 220)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: An improved "hosts" completion handling
  2006-11-08 17:23 An improved "hosts" completion handling Christopher Browne
@ 2006-11-08 17:32 ` William Scott
  2006-11-08 18:44 ` John Eikenberry
  1 sibling, 0 replies; 3+ messages in thread
From: William Scott @ 2006-11-08 17:32 UTC (permalink / raw)
  To: Christopher Browne; +Cc: zsh-users

Thanks for that.  I was using a similar trick and was now seeing that
problem and hadn't had time to track it down (too many other fires to put
out).

Christopher Browne wrote:
> I had been using some code I'd seen "out there" to pull known_hosts as
> a way of setting up a $hosts value so that ssh/telnet could do tab
> completion on host names.
>
> I think this was the source, more or less...
> http://www.2701.org/archive/200405030000.html
>
> With the changes in openssh, of late, ~/.ssh/known_hosts is now
> littered with encoded host names that were getting pulled in such that
> I'd get tab completion looking like the following:
>
> cbbrowne@dba2:~/Slony-I/slony1-HEAD-pristine> ssh rg  ssh
> rg570-da-logdbs
>   Wednesday 17:20:40
> rg570-da-logdbs
> rg570-da-logdbs1
> rg570-da-logdbs1.nj.site\ ssh-rsa\
> AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
> rg570-da-logdbs2
> rg570-da-logdbs2.nj.site\ ssh-rsa\
> AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
>
> Bleah.  That's awful.
>
> The following showed an alternative that does some better parsing, as
> well as reading IP addresses.
>
> http://www.zsh.org/mla/workers/2006/msg00280.html
>
> Here's my adaption of this:
>
> for file in $HOME/.ssh/known_hosts /etc/ssh/known_hosts; do
>   if [[ -r ${file} ]] ; then
>     _cache_hosts+=(${${${(u)${(f)"$(<${file})"}%%[
> ,|#]*}:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)})
>   fi
> done
> zstyle ':completion:*:hosts' hosts $_cache_hosts
>
> Hope that is of assistance to others...
> --
> http://linuxfinances.info/info/linuxdistributions.html
> "...  memory leaks  are  quite acceptable  in  many applications  ..."
> (Bjarne Stroustrup, The Design and Evolution of C++, page 220)
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: An improved "hosts" completion handling
  2006-11-08 17:23 An improved "hosts" completion handling Christopher Browne
  2006-11-08 17:32 ` William Scott
@ 2006-11-08 18:44 ` John Eikenberry
  1 sibling, 0 replies; 3+ messages in thread
From: John Eikenberry @ 2006-11-08 18:44 UTC (permalink / raw)
  To: zsh-users

Christopher Browne wrote:

> With the changes in openssh, of late, ~/.ssh/known_hosts is now
> littered with encoded host names that were getting pulled in such that
> I'd get tab completion looking like the following:
> 
> cbbrowne@dba2:~/Slony-I/slony1-HEAD-pristine> ssh rg  ssh
> rg570-da-logdbs
>  Wednesday 17:20:40
> rg570-da-logdbs
> rg570-da-logdbs1
> rg570-da-logdbs1.nj.site\ ssh-rsa\
> AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
> rg570-da-logdbs2
> rg570-da-logdbs2.nj.site\ ssh-rsa\
> AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
> 
> Bleah.  That's awful.

Another solution is to turn this hashing of the ssh hosts off. Just add
"HashKnownHosts no" to your .ssh/config file.

-- 

John Eikenberry
[jae@zhar.net - http://zhar.net]
______________________________________________________________
"It is difficult to produce a television documentary that is both incisive
and probing when every twelve minutes one is interrupted by twelve dancing
rabbits singing about toilet paper." - Rod Serling


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-08 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-08 17:23 An improved "hosts" completion handling Christopher Browne
2006-11-08 17:32 ` William Scott
2006-11-08 18:44 ` John Eikenberry

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).