Bug 5429 - "Неправильно" дополняются хосты для ssh/scp
: "Неправильно" дополняются хосты для ssh/scp
: Sisyphus
(All bugs in Sisyphus/zsh)
: unstable
: all Linux
: P3 enhancement
Assigned To:
  Show dependency tree
Reported: 2004-11-02 10:41 by
Modified: 2005-10-26 23:38 (History)

Патч для /usr/share/zsh/Completion/Unix/_ssh (522 bytes, patch)
2005-07-13 00:37, Sir Raorn
no flags Details | Diff
/usr/share/zsh/Completion/Unix/_known_hosts (1.10 KB, text/plain)
2005-07-13 00:39, Sir Raorn
no flags Details
/usr/share/zsh/Completion/Unix/_known_hosts (1.10 KB, text/plain)
2005-07-13 00:51, Sir Raorn
no flags Details


You need to log in before you can comment on or make changes to this bug.

Description From 2004-11-02 10:41:44
Имена хостов берутся из /etc/hosts.  Для ssh/scp есть более "доверенный"

10:19 <icct> уважаемые, напомните строчку для zsh чтоб дополняла host в ssh
10:20 <virtuoso> zstyle ':completion:*:hosts' hosts $hosts
10:20 <virtuoso> Где
10:20 <virtuoso> Например. :)

Эти команды работают (будучи помещёнными в ~/.zshrc), но хотелось бы из
(hosts= в одну строку, после '\' идёт пробел)
------- Comment #1 From 2005-03-16 21:10:56 -------
There's a few problems with what you propose.  First, it is to fail when
~/.ssh/known_hosts is nonexistent.  Second, I'm not sure I want to override
hosts style for all commands, not just for ssh and scp.  Anyway, this is going
to get too complicated for /etc/zshrc.  Maybe there should be a separate file,
perhaps in /etc/zshrc.d.
------- Comment #2 From 2005-03-16 23:02:54 -------
Separate file должен быть в районе /usr/share/zsh/Completion/Unix/_sshhosts, но
у меня сходу не получилось научить _ssh_hosts брать hosts из
~/.ssh/known_hosts... Будем надеяться, что LATER кто-ньдь что-ньдь сделает. 
Например я разберусь с zsh Completion System...
------- Comment #3 From 2005-07-13 00:36:31 -------
LATER наступило.  Патчи в аттачах.
------- Comment #4 From 2005-07-13 00:37:49 -------
Created an attachment (id=983) [details]
Патч для /usr/share/zsh/Completion/Unix/_ssh
------- Comment #5 From 2005-07-13 00:39:30 -------
Created an attachment (id=984) [details]

Из ~/.zsh/functions почему-то не autoload'ится.  Почему - пока не понял.
------- Comment #6 From 2005-07-13 00:43:38 -------
Смысл такой:

Перебираем ssh_config в составе /etc/ssh/ssh_config /etc/ssh2/ssh_config
/etc/openssh/ssh_config $HOME/.ssh/config $HOME/.ssh/config, из каждого файла
выцепляем параметры:

1. Host с non-pattern аргументом, добавляем к списку вариантов.
2. Global/UserKnownHostsFile, если не определено, используем
/etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts
/etc/known_hosts2 $HOME/.ssh/known_hosts $HOME/.ssh/known_hosts2, и выдираем из
этих файлов хосты.
------- Comment #7 From 2005-07-13 00:51:58 -------
Created an attachment (id=985) [details]
------- Comment #8 From 2005-07-13 09:11:42 -------
о та!
------- Comment #9 From 2005-07-18 12:09:20 -------
$HOME/.ssh/known_hosts listed twice in "for" loop condition.  Did you mean
------- Comment #10 From 2005-07-18 12:10:37 -------
I mean "config2".
-    for f in /etc/ssh/ssh_config /etc/ssh2/ssh_config /etc/openssh/ssh_config
$HOME/.ssh/config $HOME/.ssh/config; do
+    for f in /etc/ssh/ssh_config /etc/ssh2/ssh_config /etc/openssh/ssh_config
$HOME/.ssh/config $HOME/.ssh/config2; do

------- Comment #11 From 2005-07-18 12:23:21 -------
(In reply to comment #10)
> I mean "config2".

My mistake.  ~/.ssh2/config.

I think these paths must be sanitized.  I've loooked into
/etc/bash_completion(_known_hosts) and added /etc/openssh/.  I'm not sure where
"popular" ssh implementations keeps their configs.  Original list:

/etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config

Global known_hosts:
/etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts
/etc/known_hosts2 /etc/ssh2/knownhosts/*pub

User known_hosts:
~/.ssh/known_hosts ~/.ssh/known_hosts2 ~/.ssh2/hostkeys/*pub

knownhosts/hostkeys directories is not supported (yet?).  Also missing
/usr/local/etc/ paths that can be used on *BSD.

P.S. Is there any way to determine ssh config/known_hosts file at runtime?
------- Comment #12 From 2005-07-21 23:39:46 -------
Fixed in zsh-4.3.0-alt0.2.