3 ms·
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/confi
by INTPenis 13y ago
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.
- shabble 13y agoWith 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 http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config
- mnem 13y agoI had no idea that existed, thanks! Time to rewrite my configs...
- voltagex_ 13y agoHoly 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.