sshconfig icon indicating copy to clipboard operation
sshconfig copied to clipboard

Manage section of ssh config?

Open mb-dev opened this issue 5 years ago • 1 comments

Hello,

This seems like a great tool and i am looking to automate managing .ssh/config. I am wondering if sshconfig can also manage a section in ssh config file instead of the entire file?

I imagine some sections will be added manually but I want to programmatically alter a few settings.

mb-dev avatar Aug 21 '20 18:08 mb-dev

If you would like to programmatically alter a few sections, perhaps the best way to handle that is to exploit the fact that the config files are Python and simply program the config files themselves. I do this because some of my hosts are archaic Centos-6 hosts and so cannot use modern SSH algorithms. The config file is written in such a way as to recognize this archaic hosts, in which case they specify the user of older algorithms. There is also the OVERRIDES and DEFAULTS settings. It would be possible to write Python code to grab the contents of an existing file and include them in one of these two settings (DEFAULTS gets inserted at the top of the .ssh/config file, and OVERRIDES is inserted at the end). Are you comfortable with Python programming?

An alternative would be for me to add the ability to insert the contents of one or more files into the config file it generates.

Yet another alternative would be to enhance sshconfig to allow you to specify a post-processing script that would be run after sshconfig has been run. Then you could use CONFIG_FILE to change the default location of the generated config file, and then the script could combine the generated and the existing config files.

Would any of these approaches work for you?

KenKundert avatar Aug 22 '20 01:08 KenKundert