From f054e9dea98bf56c8ea068dc279e99e76a334848 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 8 Jun 2019 11:43:38 -0300 Subject: Generate UserKnownHostsFile dynamically instead of when rotating keys The previous solution would hardcode the server IP. This way we can change the server IP address that is hosting everything and keep the SSH keypair. Previously changing the IP address would require either calling the =./rotate-ssh-keys.sh= script or manually changing the IP address on the known-hosts.txt file. The IP address being duplicated itself was a code smell. Both SSH keypair and IP address can now be changed independently. --- rotate-ssh-keys.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'rotate-ssh-keys.sh') diff --git a/rotate-ssh-keys.sh b/rotate-ssh-keys.sh index 4369002..7189657 100755 --- a/rotate-ssh-keys.sh +++ b/rotate-ssh-keys.sh @@ -5,8 +5,6 @@ cd "$(dirname "${BASH_SOURCE[0]}")" rm -f ./secrets/ssh/* ssh-keygen -t rsa -b 4096 -q -N '' -f ./secrets/ssh/vps-box-client ssh-keygen -t rsa -b 4096 -q -N '' -f ./secrets/ssh/vps-box-server -PUBLIC_KEY="$(awk '{print $2}' < ./secrets/ssh/vps-box-server.pub)" -echo "${TLD},${PINNED_IP} ssh-rsa ${PUBLIC_KEY}" > ./secrets/ssh/known-hosts.txt git add ./secrets/ssh/ git commit -m "Script: rotate SSH keys" -- cgit v1.2.3