9 comments

[ 1.7 ms ] story [ 30.2 ms ] thread
I've seen storm, it seems like it does way more than all I want, which is just to make believe .ssh/config.d is a thing.

So I just do that: https://github.com/Julian/dotfiles/blob/master/.config/zsh/....

And then just go on editing files.

(What I really want, which is another story, is a terser way to use knife ssh with queries, so that I can ssh around by service name and environment, but I haven't gotten a chance to write this in a fast enough form)

> (What I really want, which is another story, is a terser way to use knife ssh with queries, so that I can ssh around by service name and environment, but I haven't gotten a chance to write this in a fast enough form)

Curious how that would look?

What I really want from a dynamic .ssh/config file is a way to specify conditional options.

For example, today my .ssh/config is a symlink to either .ssh/config-home or .ssh/config-out on my laptop. If I'm out I use the config-out file but if I'm on my home VPN or at home I use config-home.

Also I have a ProxyCommand for many work servers so I proxy through my work laptop that is always on and this command is not needed if I'm in my work network.

So in two ways the only thing I ever needed from a dynamic ssh configuration is conditional options based on my network location. Today I change this manually with a script and symlinks, but have to maintain two different configurations.

Edit: I just realized while typing this that one solution would be to use a jinja2 template for my ssh_config instead of maintaining two different files.

With relatively recent ssh versions you can use the Match directive[1] inside your config file to do various conditional things.

Then you could do something like this:

    Host foo
      Hostname foo.example.com
      Match exec 'at_home_test.sh'
        Hostname vpn-gw.example.com
        Proxycommand ...
[1] http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config
I had no idea that existed, thanks! Time to rewrite my configs...
Holy crap, this needed to be in the SSH Kung Fu article. I wonder how to do a network test without slowing the ssh command down too much. At a certain point it becomes faster to type outsidednsname.voltagex.org than to wait for the match to execute.
I dunno, vim has always been the most useful command line tool to my manage my ssh config file. Maybe that's just me though.
Same here, but I work with a couple of developers who fear the command line (yes, I know) so this is still pretty useful.
Can you please remove your dependence on winrandom, and perhaps test it on python 3.4 + windows? Could not install winrandom on windows (2.7 only lib?).