Skip to content

Instantly share code, notes, and snippets.

@discordianfish
discordianfish / ec2-update-known-hosts
Created March 12, 2015 13:54
Tool to update your ssh's known_hosts based on the cloud-init output on AWS EC2
#!/bin/bash
set -e
readonly TMP=$(mktemp)
trap "rm $TMP" EXIT
aws ec2 describe-instances | \
jq -r '.Reservations|map(.Instances)|map(.[])|map([.PrivateIpAddress,.InstanceId])[]|join(",")' | \
while read l
do
ip=$(echo $l | cut -d, -f1)