- Create the following folder structure in your ~/.ssh/ folder:
- ~/.ssh/config-and-keys/
- ~/.ssh/config-and-keys/keys/
- ~/.ssh/config-and-keys/config.d/
- Store all your ssh-keys (public AND private) in ~/.ssh/config-and-keys/keys/
- Store all your ssh config files in ~/.ssh/config-and-keys/config.d/ (config-work, config-private, ...).
- Save config.d-create-symlinks.sh and config.d-gen.sh to ~/.ssh/config-and-keys/
- Run ~/.ssh/config-and-keys/config.d-create-symlinks.sh - it will create the necessary symlinks to your ~/.ssh/ folder.
- Run ~/.ssh/config-and-keys/config.d-gen.sh - it will create your single ~/.ssh/config file SSH can handle.
Run ~/.ssh/config-and-keys/config.d-create-symlinks.sh every time you add a new key and ~/.ssh/config.d-gen.sh every time you change one of your SSH config files.
You can now init a git repository in ~/.ssh/config-and-keys and push it to a trusted location (preferably using SSH) for backup and deployment to all your machines.
Create symlinks to the contents of the keys/ folder (~/.ssh/), the config.d-gen.sh script and and the config.d directory; and make sure all files have the right file permissions.
Backup old config file and create a new ~/.ssh/config file from (the symlink) ~/.ssh/config.d/* and make sure that the file permissions are correct for the configuration.