💾 Archived View for alltext.umaneti.net › gemlog › edgar.gmi captured on 2024-07-08 at 23:28:09. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
I take some times to write a new utility for my day to day work: Edgar[1].
`edgar' is a small utility to help one maintain their huge SSH config file. It's heavilly inspired by concierge[2] (even the tests are directly taken from the `concierge' examples!).
`edgar' only support python3. We are now in 2019!
virtualenv edgar-venv source edgar-venv/bin/activate python setup.py install
Contrary to `concierge', there is no inotify support. The main idea is that you are not always modifying your SSH config file and it's not that hard to just call manually `edgar' when your config template is ready.
`edgar' rely on a config file stored in your `~/.config' folder: `~/.config/edgar.yml'. As its name show it, this is a YAML file.
This file should contain a list of host configurations. Thus the most simple config file may be:
--- - Host: m1 HostName: 192.168.1.42 User: edgar - Host: m2 HostName: 192.168.1.43 User: edgar
Which will output the following:
Host m1 HostName 192.168.1.42 User edgar Host m2 HostName 192.168.1.43 User edgar
If the main object is not a list, it is taken as a primary host configuration named `*':
--- Compression: yes ServerAliveInterval: 120 ServerAliveCountMax: 2 UseRoaming: no HashKnownHosts: yes IdentitiesOnly: yes AddKeysToAgent: yes hosts: - Host: m1 HostName: 192.168.1.42 User: edgar - Host: m2 HostName: 192.168.1.43 User: edgar
Which will output the following:
Host * Compression yes ServerAliveInterval 120 ServerAliveCountMax 2 UseRoaming no HashKnownHosts yes IdentitiesOnly yes AddKeysToAgent yes Host m1 HostName 192.168.1.42 User edgar Host m2 HostName 192.168.1.43 User edgar
Finally, `edgar' understands sub-hosts and ansible-like `with_items' processing:
--- Compression: yes ServerAliveInterval: 120 ServerAliveCountMax: 2 UseRoaming: no HashKnownHosts: yes IdentitiesOnly: yes AddKeysToAgent: yes hosts: - Host: m User: edgar Protocol: 2 hide: yes hosts: - Host: e{item} HostName: 10.10.0.{item} ViaProxy: gw2 with_items: range(2) - Host: blog User: sa
Which will output the following:
Host * Compression yes ServerAliveInterval 120 ServerAliveCountMax 2 UseRoaming no HashKnownHosts yes IdentitiesOnly yes AddKeysToAgent yes Host me0 User edgar Protocol 2 HostName 10.10.0.0 ProxyCommand ssh -W %h:%p gw2 Host me1 User edgar Protocol 2 HostName 10.10.0.1 ProxyCommand ssh -W %h:%p gw2 Host blog User sa
`edgar' understands all SSH config parameter, only if they are well written (there is no attempt to add missing capital).
It understands the following supplementary commands:
1. Don't forget to add the colon between the SSH parameter and its value.
2. Some values must be protected, like the one with `*'. For exemple: `Host: "*.toto.com"'.
--
📅 vendredi 22 novembre 2019 à 22:36
📝 Étienne Deparis with GNU/Emacs 29.4 (Org mode 9.7.6)