3 ms·
Another trick I use is to put all of my stuff into .ssh/config.d/ and then run `ssh-compile` and it generates .ssh/config for me. This lets me pull in new conf
by nvahalik 4y ago
Another trick I use is to put all of my stuff into .ssh/config.d/ and then run `ssh-compile` and it generates .ssh/config for me.
This lets me pull in new config files and hosts without having to redo everything every time.
- CamJN 4y agoOr you can add this to the top of your ssh config file: `Include ~/.ssh/config.d/*`
- sneak 4y agoBonus points if you put the config.d dir in a Syncthing folder and synchronize it to all your workstations.
- aidos 4y agoOh that’s nice.
- nvahalik 4y agoDoes this honor the rc.d prefixes? Eg 0- files go first and then alphabetical? Edit to say that my compile function does a syntax check too… but this is easier than setting up the dir listener.
- CamJN 4y agoI dunno, I think it does “glob-order” which should be alphabetical adjacent.
- n8henrie 4y agoRedo everything? Redo what? I just add a new entry to the bottom, `nvim ~/.ssh/config` -- what is better about your approach / what am I missing out on? (Have never heard of ssh-compile, will also look it up when not on mobile.)
- nvahalik 4y agossh-compile is my script... It's basically this: #!/bin/sh SSH_DIR="/Users/nvahalik/.ssh/config.d/" echo "" > ~/.ssh/config for i in `ls "${SSH_DIR}"`; do echo "# ${SSH_DIR}${i}" >> ~/.ssh/config cat "${SSH_DIR}${i}" >> ~/.ssh/config echo "\n" >> ~/.ssh/config done; chmod 644 ~/.ssh/config
- deleted 4y ago[deleted]
- artificialLimbs 4y agoWhat I do for my homelab vms and such: # If ~/.ssh/config does not exist, copy file if [ ! -f ~/.ssh/config ]; then cp ./.ssh/config ~/.ssh/config else # For each block in ./.ssh/config, if it is not in ~/.ssh/config, add it while read -r line; do if [[ "$line" == "" ]]; then if grep -q "$block" ~/.ssh/config; then # If block is not found, add it to ~/.ssh/config echo "$block" >> ~/.ssh/config fi else if [[ -z "$block" ]]; then block="$line" else block="$block$line\n" fi fi done < ./.ssh/config fi
- dolmen 4y agoOpenSSH now has an Include directive.