Skip to content

Instantly share code, notes, and snippets.

@AshtonKem
Created August 27, 2013 19:48
Show Gist options
  • Save AshtonKem/6358204 to your computer and use it in GitHub Desktop.
Save AshtonKem/6358204 to your computer and use it in GitHub Desktop.
update-ssh-config() {
rm ~/.ssh/config
echo "### This file is generated! Please check ~/.ssh/clean_config" > ~/.ssh/config
cat ~/.ssh/clean_config >> ~/.ssh/config
echo "### KNIFE NODES ###" >> ~/.ssh/config
knife search node "name:*" -a ec2.public_hostname | awk 'BEGIN {RS = "" ; FS = "\n" ; } { if (length(substr($1, 23, 1000)) != 0) {print "Host ", substr($2, 23, 1000) ;print " User akemerling" ;print " Hostname", substr($1, 23, 1000); print "" ;}}' | tail -n +1 >> ~/.ssh/config
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment