Posts tagged ‘private’

Using zsh as default shell is perfect. Using grml-zsh stuff to configure it, even better. Using XTaran’s config, way better. Using your own config, invaluable. Now, there is one thing that always bothered me: having all hosts I usually deal with in my ~/.ssh/config in order to have tab completion (and short names). I wanted to improve the situation and was kindly pointed in a different direction by Myon, namely to just use the ~/.ssh/known_hosts for tab completion. How about that?

I started playing around with the config and, as it turns out, Axel already has something ready. Unfortunately, it didn’t fulfill all my needs yet. That is because I have multiple known_hosts files. Martin already filed a bug to have ssh read ~/.ssh/known_hosts.d/* but that isn’t resolved yet either, even though upstream is aware of it. I thus had to point tab completion and ssh to multiple files by hand. But that’s not too bad for now. Let’s have a look:

Host *
        HashKnownHosts no

Host *.your-work.com
        User that-is-what-they-call-me-at-work
        UserKnownHostsFile ~/.ssh/known_hosts.work

Host *.debian.org
        UserKnownHostsFile ~/.ssh/known_hosts.debian

What am I doing? Well, we need to deactivate the hashing of known hosts. Otherwise your known_hosts files aren’t readable as needed. Then you define your known_hosts files for the domains you care about. Pretty straight forward.

Now, how about tab completion in zsh? Well, easy part actually:

[ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} [ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}} [ -f ~/.ssh/known_hosts.work ] && : ${(A)ssh_known_hosts_work:=${${${(f)"$(<$HOME/.ssh/known_hosts.work)"}%%\ *}%%,*}} [ -f ~/.ssh/known_hosts.debian ] && : ${(A)ssh_known_hosts_debian:=${${${(f)"$(<$HOME/.ssh/known_hosts.debian)"}%%\ *}%%,*}} zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian

What's here? We read and parse your ~/.ssh/config for configured hosts, then we parse all your known_hosts files which are for me: ~/.ssh/known_hosts, ~/.ssh/known_hosts.work, and ~/.ssh/known_hosts.debian. And lastly, all is added to zsh completion for hosts. That actually works. :)

Axel, that makes a diff for you looking like this:

diff --git a/zsh.d/70-completion b/zsh.d/70-completion
index e92e068..5abf5cc 100644
--- a/zsh.d/70-completion
+++ b/zsh.d/70-completion
@@ -8,6 +8,8 @@

[ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} [ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}} +[ -f ~/.ssh/known_hosts.work ] && : ${(A)ssh_known_hosts_work:=${${${(f)"$(<$HOME/.ssh/known_hosts.work)"}%%\ *}%%,*}} +[ -f ~/.ssh/known_hosts.debian ] && : ${(A)ssh_known_hosts_debian:=${${${(f)"$(<$HOME/.ssh/known_hosts.debian)"}%%\ *}%%,*}} -zstyle ':completion:*:*:*' hosts $ssh_config_hosts $ssh_known_hosts +zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian

Care to merge?

Oh, and before I forget... Of course you don't need to check each and every host by yourself. Debian provides ssh keys for all hosts on master. Just do a

scp master.debian.org:/etc/ssh/ssh_known_hosts ~/.ssh/known_hosts.debian

and I'm sure, your security aware employer has such a file for you as well. Doesn't he? ;)

In einer Zeit, in der förmlich alles im Internet abgehandelt wird, in der die Sekunden schneller gehen als je zuvor, in der die Menschen keine Zeit mehr haben, auf ein persönliches Treffen zu warten oder kurz anzurufen; in einer Zeit, in der man nur schnell mal was fragen wollte, um dann schon zum nächsten Tagesordnungspunkt überzugehen; in einer solchen Zeit beschloss ich, eine Freundin nach der Telefonnummer von ihrem Frisör zu fragen, die ich von anderer Quelle nicht in Erfahrung bringen konnte, denn, wer mich kennt, weiß, dass ich das mal wieder nötig habe. Leider war meine Frage wohl zu lang, um über den Facebook-Chat zu wandern, also schrieb ich sie ihr in einer Facebook-Message. Dabei hab ich mich extra kurz gefasst:

Liebe Zeitgenossin, mir ist zuweilen vorgetragen worden, dass, und solches stelle man sich ersteinmal vor, obgleich doch es wenig überraschend ist, bedenkt man, um wen es sich handelt, du ganz im Gegensatz zu ihr im stolzen Besitze dessen bist, das mir zueigen gemacht sich gar lohnen würde, wenn auch der Ausgang des angestrebten Unterfangens noch umnachtet, will sagen: in greifbarer und dennoch unklarer Ferne zu liegen scheint. Aus diesem Grunde nun würde ich meine Verbundenheit zu deiner Person außerdordentlich zum Ausdruck bringen wollen, wenn nun du, so deine bezaubernde Güte es zulässt, mir unter die Arme greiftest, um mir zu geben, was sie mir nicht geben konnte angesichts ihrer erstaunlichen Besitzlosigkeit. Was dieses etwas, dessen ich mich ermächtigen will, nun ist, wird deinen Geiste wohl beschäftigen, und es liegt mir fern, mich der Werkzeuge verbaler Folter zu bedienen, um zu spannen, was zu spannen sich nun nicht mehr gehört. Es liegt mir nämlich zweierlei am Herzen: zum einen, deine unermässliche Güte und Zuneigung nicht zu strapazieren, zum anderen, mein Anliegen einer Endgültigkeit näher zu bringen. Daher möchte ich darum bitten, holde Maid, dass du mir an ihrer Stelle die Ehre erweisest und mir mitteiltest, wie die Nummer derjenigen, die deiner Kopfbedeckung ständig so zuträglich ist, lautet, sodass ich mit ihr eine Unterredung und mögliche Behandlung meines dir bekanntes Dilemmas vereinbaren kann. Ich hoffe, selbiges liegt so weit auch in deinem Interesse, dass du mir diesen Gefallen nicht abschlägst und mich so zu einem glücklichen Freund an deiner Seite machst, der, wie angedeutet, tief in deiner Schuld stünde.

Countless times already have I used Google’s amazing feature called maps. Admittedly, if you know me, you might wonder how I can be advertising Google. At least as often as I used google maps, I have told people about google’s evilness. They’re making their users transparent in ways most people can’t even imagine — transparent to other users (just like Facebook does) but, more importantly, transparent to themselves and their advertising customers. Technically skilled people reading my blog probably just nod and scoll down now… :) Well, there still is something about Google that makes me use their developments: they are good. I don’t know any other online service to create own maps, get directions etc. with as much detail and huge amount of data as google delivers. Thus, Google maps became my main source for locations and directions world wide. As such, I wanted to use it to get directions between places in Berlin, Germany. Apparently, Google’s software had some kind of hick up or whatever, though. They got the directions right but somehow I doubt the map is anyhow related to what I requested. See for yourself…Google maps irritatedYes, yes, no software is perfect… but still :)

It’s pretty off topic for my blog since I usually only blog about technical stuff. But this is just great. Real life people having a real look at concerts of prominent and not-so-prominent musicians. And it’s all in German which is a nice thing since most of such stuff I have to find on English web sites (except the obvious German big press influence). Made me notice I missed the concert of Jamie Cullum — of course. But the article is quite nice and I definitely enjoy reading more of those. Have a look if you’re as keen on music as I am, or not. :)

27

Sorry for the noise… but it’s always the same. When it happens I can’t really believe it. No, not my birthday is unbelievable… I do trust the calendar. It’s the fact that I’m 27 now. I mean, I’m supposed to be grown up, ain’t I? I don’t think it’s happening soon…