Last active
February 23, 2024 09:31
-
-
Save zealot128/912e237d28e4acfed8a9c64903535905 to your computer and use it in GitHub Desktop.
Ansible: remove known hostkey from all hosts to fix mismatching host key after host recreation
This file contains 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
# Needs jq | |
hosts=`ansible-inventory --list | awk -F': "' '/ansible_host/ {print $2}' | cut -d'"' -f1` | |
echo $hosts | xargs -I {} ssh-keygen -R {} | |
echo $hosts | xargs -I {} ssh-keyscan {} >> ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment