2022-01-25 23:54:43 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-04-01 00:44:23 -05:00
|
|
|
# File: ./generate-ssh-keyscan
|
2022-01-25 23:54:43 -06:00
|
|
|
#
|
|
|
|
# Description: This file generates a known_host block for the inventory.
|
|
|
|
#
|
|
|
|
# Package: AniNIX/HelloWorld
|
|
|
|
# Copyright: WTFPL
|
|
|
|
#
|
|
|
|
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
|
|
|
|
|
|
|
|
inventory="$1"
|
|
|
|
|
|
|
|
replicadomain="$(grep replica_domain:\ "$inventory" | awk '{ print $2; }';)"
|
|
|
|
|
|
|
|
for short in `ansible -i "$inventory" --list-hosts managed | grep -v hosts | sed 's/^\s\+//'`; do
|
|
|
|
long="$short"'.'"$replicadomain"
|
|
|
|
ip="$(dig "$long" +short)"
|
|
|
|
ssh-keyscan -t ed25519 -f <(echo "$long" "$long","$short","$ip") 2>&1
|
|
|
|
ssh-keyscan -t rsa -f <(echo "$long" "$long","$short","$ip") 2>/dev/null
|
|
|
|
done
|