kurgan kurganme
2025-Jan-07 16:48 UTC
[PATCH] permits multiple tags on a configuration block.
Hello all. I wrote this small patch that allows having multiple tags on a configuration block in the openssh client configuration. For instance, with this configuration:> Host test-host > Tag change-hostname change-port-and-user > Tag jump-to-mybox > > Match tagged change-hostname > Hostname new-hostname > > Match tagged change-port-and-user > Port 12345 > Tag change-user > > Match tagged change-user > User bilbo > > Match tagged jump-to-mybox > ProxyJump mybox > > Match tagged nocheck > StrictHostKeyChecking false > UserKnownHostsFile /dev/null > > Match tagged frodo-identity > IdentityFile ~/.ssh/id_ed25519_frodothe following parameters can be obtained:> gandalf at mybox $ ssh -P nocheck -P frodo-identity test-host -G | > > grep -E "^(user|hostname|port|stricthostkeychecking|identityfile|`> > `userknownhostsfile|tag|proxyjump) " > user bilbo > hostname new-hostname > port 12345 > stricthostkeychecking false > identityfile ~/.ssh/id_ed25519_frodo > userknownhostsfile /dev/null > tag nocheck > tag frodo-identity > tag change-hostname > tag change-port-and-user > tag jump-to-mybox > tag change-user > proxyjump mybox > gandalf at mybox $Obviously, this is just an example of use, and such brief match blocks are not useful in real cases. The example is only meant to demonstrate the potential of the modification. In the example, I also added multiple tags from the command line with the `-P` option. I believe this change is very convenient for having a sort of multiple inheritance in configuration files. I hope you find it interesting. Regards -- vincenzo -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Make-it-possible-to-have-multiple-tags-on-a-configur.patch Type: text/x-patch Size: 4229 bytes Desc: not available URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20250107/9f00cce2/attachment-0001.bin>
Brian Candler
2025-Jan-07 17:26 UTC
[PATCH] permits multiple tags on a configuration block.
On 07/01/2025 16:48, kurgan kurganme wrote:> I wrote this small patch that allows having multiple tags on a > configuration block in the openssh client configuration. > For instance, with this configuration: > >> Host test-host >> Tag change-hostname change-port-and-user >> Tag jump-to-mybox >> >> Match tagged change-hostname >> Hostname new-hostname >> >> Match tagged change-port-and-user >> Port 12345 >> Tag change-user >> >> Match tagged change-user >> User bilbo >> >> Match tagged jump-to-mybox >> ProxyJump mybox >> >> Match tagged nocheck >> StrictHostKeyChecking false >> UserKnownHostsFile /dev/null >> >> Match tagged frodo-identity >> IdentityFile ~/.ssh/id_ed25519_frodoCould this not be done using the "Include" directive? ssh_config(5) says: "Files without absolute paths are assumed to be in ~/.ssh if included in a user configuration file [...] Include directive may appear inside a Match or Host block to perform conditional inclusion." which suggests: Host test-host ? Include change_hostname.conf ? Include change_port_and_user.conf ? Include jump_to_mybox.conf ...