Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve the existing known hosts information when ssh-keyscan encounters an issue #9

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/update-known-hosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

log("Fetching the list of regions from the API...");

// Read the existing known_hosts file.
$existing_known_hosts = [];
$e_filename = __DIR__ . '/../known_hosts';
if (\file_exists($e_filename)) {
$known_hosts_lines = \file($e_filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Build an associative array based on domain key.
foreach ($known_hosts_lines as $line) {
[$e_domain, ] = \explode(' ', trim($line));
$existing_known_hosts[trim($e_domain)] = $line;
}
}

$json = run($cliCommand . ' api:curl ' . escapeshellarg('/regions?filter[private]=0'));
$regions = $json ? \json_decode($json, true) : [];
if (!$regions || empty($regions['regions'])) {
Expand Down Expand Up @@ -39,6 +52,10 @@
if ($output = run('ssh-keyscan ' . \escapeshellarg($prefix . $domain) . ' 2>/dev/null')) {
$known_hosts[] = trim($output);
}
elseif (isset($existing_known_hosts[$prefix . $domain])) {
// Use the existing record as fallback if ssh-keyscan fails.
$known_hosts[] = $existing_known_hosts[$prefix . $domain];
}
$i++;
}
}
Expand Down
3 changes: 3 additions & 0 deletions known_hosts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ git.eu.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDo0sNDnrxZ4N0UEFhdgYmX5
ssh.eu.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDo0sNDnrxZ4N0UEFhdgY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OamfJi/b1CajNZr6Q3gs7oqRbWBt9mgDFU9sFDMWDmmBAvDQj2azSk2i1hFQ4/lzczt6vQH9vusnESPCJfAiMJb60868BhuvOV9oxITItzwgNDFJltL8LNadZ4x6VvMmPV0DpJb
ssh.eu-5.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHVvr73G2u1j0s0RqixwpIGsTKagv3vMErXj/ixorbbuuNFmln8l2OqLo9cvg6QmO8OJFpY1xdOAIQ1hfzcZud+LCdMAxvsC7lz9VMb26Vchuc7o+lq0+w8ORAlKqlFfl2MpLtbEuuRaellXaTlQ36cSKwuCHOfzqsKDyb+Umpm+bYk6ICLnJyiEldo1cs8cAQNIgXRmPiJ2Ws/OamfJi/b1CajNZr6Q3gs7oqRbWBt9mgDFU9sFDMWDmmBAvDQj2azSk2i1hFQ4/lzczt6vQH9vusnESPCJfAiMJb60868BhuvOV9oxITItzwgNDFJltL8LNadZ4x6VvMmPV0DpJb
Expand All @@ -19,7 +20,9 @@ git.fr-4.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvCpjQnnCR6VDXTL/neY5
ssh.fr-4.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvCpjQnnCR6VDXTL/neY5wqIe7Z1OUSxdLMqDCGpkDSLTN7I9Jj8MvMR1A0nuehwRpV1kHFJ4HryPyFGvR9BSFib4VZ1cd51iTSbphDkpbp3E7ukNzqV445+iPEwRPNDzJFKL3z/C7RR9ss6crP5h1Cn/qQaxjVTZry+zmv0IgSIkb3ipCN6QL6nXUOsabk4YB4YiVUlQWSNizWNn5cFOvby7DCd/lzlOz2zR7fgD2Cjbzs+2uz832r2wb2CnsVMAdGOs/MnlPy7RS16h6wa8M10UxJztTESdJ8zj1qbToPQyKHILpSSX3+E2wrrdVJ3OeG2skwElp/EhHAjcv7C65
git.uk-1.platform.sh ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+zGy0b99QbRYBuHtym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