Created
August 18, 2016 19:17
-
-
Save EntropyWorks/152e96e264c066209d392ba7aa528136 to your computer and use it in GitHub Desktop.
Managing my ~/.ssh/config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _verify_sshconfig(){ | |
| # Using GnuPG to verify my ~/.ssh/config | |
| # | |
| # In ~/.ssh/config.d/ create your ssh config like this | |
| # | |
| # 00-header.cfg | |
| # 05-work.cfg | |
| # ... | |
| # 20-other.cfg | |
| # 99-defaults.cfg | |
| # | |
| # cat them all together into the new config. | |
| cat ~/.ssh/config.d/*.cfg > ~/.ssh/config.new | |
| # GnuPG to verify my new config is the same | |
| gpg --verify ~/.ssh/config.sig ~/.ssh/config.new | |
| if [ $? -ne 0 ] ; then | |
| diff -u ~/.ssh/config ~/.ssh/config.new | |
| echo "_______________________________________________________________" | |
| echo -n "FAILED GnuPGP Signature! Do you want to resign it now? [y/N]: " | |
| read ANS | |
| case $ANS in | |
| y|Y) | |
| cat ~/.ssh/config.new > ~/.ssh/config | |
| gpg --output ~/.ssh/config.sig --detach-sign ~/.ssh/config | |
| ;; | |
| *) | |
| echo "You will need to re-sign your ~/.ssh/config again" | |
| echo " gpg --output ~/.ssh/config.sig --detach-sign ~/.ssh/config" | |
| ;; | |
| esac | |
| else | |
| # Since it is lets cat the new one into the old. | |
| cat ~/.ssh/config.new > ~/.ssh/config | |
| /usr/bin/ssh $@ | |
| fi | |
| } | |
| # All ssh options are passed along | |
| alias ssh='[[ -d ~/.ssh/config.d ]] && _verify_sshconfig' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment