diff --git a/infrastructure/environments/update-known-hosts.sh b/infrastructure/environments/update-known-hosts.sh index 8675467d9..65fc7c29a 100644 --- a/infrastructure/environments/update-known-hosts.sh +++ b/infrastructure/environments/update-known-hosts.sh @@ -9,6 +9,7 @@ if [ "$#" -ne 1 ]; then fi DOMAIN=$1 +IP=$(dig +short $DOMAIN) KNOWN_HOSTS_FILE="infrastructure/known-hosts" # Ensure the known-hosts file exist @@ -16,6 +17,7 @@ touch "$KNOWN_HOSTS_FILE" # Remove existing entry for the domain from the known-hosts file ssh-keygen -R "$DOMAIN" -f "$KNOWN_HOSTS_FILE" || true +ssh-keygen -R "$IP" -f "$KNOWN_HOSTS_FILE" || true # Initialize keyscan result variable KEYSCAN_RESULT="" @@ -23,7 +25,7 @@ KEYSCAN_RESULT="" # Attempt to fetch the new SSH public key for the domain while [ -z "$KEYSCAN_RESULT" ]; do # Use `|| true` to prevent script exit if ssh-keyscan fails - KEYSCAN_RESULT=$(ssh-keyscan "$DOMAIN" 2>/dev/null) || true + KEYSCAN_RESULT=$(ssh-keyscan "$DOMAIN" "$IP" 2>/dev/null) || true # Check if ssh-keyscan was successful if [ -z "$KEYSCAN_RESULT" ]; then diff --git a/infrastructure/known-hosts b/infrastructure/known-hosts index c8935b3c9..b4c56f5ff 100644 --- a/infrastructure/known-hosts +++ b/infrastructure/known-hosts @@ -10,3 +10,6 @@ farajaland-qa.opencrvs.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGSIBuxNbsqj+NYkQ farajaland-dev.opencrvs.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZVo8Jsqw6akzCRm8ID0zd2OAxU5NeOvS/iE3win98w farajaland-dev.opencrvs.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDWFbOMgypl/mCjtTbnYQl4CRMxV/pp/7FupLnVnabFFeBv5OECrFTku3zV1n2hmbQZNJdO3gREQeV67olSBg554wp8CLJoE2l0SV1Gg56zz58H79Smhl2dnSZEtEELr5NqZ6cFWa7mwXEfS0Xp+oaWbc+ieLcQcC58l6HE8K/ygBzqNhgHqSJsY7PFmk+UFnbaF6zDqF5I4SJ6LP3299SPtzxrAkxuo4UM/QETDfjj/oc42XqKa3anzbk8rtupVETm/h8akx5D4XzGaSjENpAj9IGFUNg6oiLsw6GeWPTQTf1b7exsWs0y95yTIxWB8o/0XE9vauftICsEgThkmp+XZW81uhLmGKEsKzf9Leil6U3fkYkNeEf4V9DjisEWwq89Q31hOWnilbgEJbb5u+l+aeEK/MKeo2Epx0SZckLwo3YmL6vM00ykIzqrS3ERw/K1GGSmZtBIplDALJWLt0OZR3vwnktR/4oj6+Iy1PuIa9i+bw0OVo8ScolgRHxZok8= farajaland-dev.opencrvs.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC6FQAe/NJr47AbOwedQoK9+pIgaiBte1c66fLTSsNnWiBEvte4JL4ar+DHtbjhE8Huzui+Bn9U/JFo/VzgTWzQ= +104.248.36.17 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZVo8Jsqw6akzCRm8ID0zd2OAxU5NeOvS/iE3win98w +104.248.36.17 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDWFbOMgypl/mCjtTbnYQl4CRMxV/pp/7FupLnVnabFFeBv5OECrFTku3zV1n2hmbQZNJdO3gREQeV67olSBg554wp8CLJoE2l0SV1Gg56zz58H79Smhl2dnSZEtEELr5NqZ6cFWa7mwXEfS0Xp+oaWbc+ieLcQcC58l6HE8K/ygBzqNhgHqSJsY7PFmk+UFnbaF6zDqF5I4SJ6LP3299SPtzxrAkxuo4UM/QETDfjj/oc42XqKa3anzbk8rtupVETm/h8akx5D4XzGaSjENpAj9IGFUNg6oiLsw6GeWPTQTf1b7exsWs0y95yTIxWB8o/0XE9vauftICsEgThkmp+XZW81uhLmGKEsKzf9Leil6U3fkYkNeEf4V9DjisEWwq89Q31hOWnilbgEJbb5u+l+aeEK/MKeo2Epx0SZckLwo3YmL6vM00ykIzqrS3ERw/K1GGSmZtBIplDALJWLt0OZR3vwnktR/4oj6+Iy1PuIa9i+bw0OVo8ScolgRHxZok8= +104.248.36.17 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC6FQAe/NJr47AbOwedQoK9+pIgaiBte1c66fLTSsNnWiBEvte4JL4ar+DHtbjhE8Huzui+Bn9U/JFo/VzgTWzQ=