[tor-commits] [metrics-cloud/master] cloudformation: Allow SSH key to be overriden with env

irl at torproject.org irl at torproject.org
Wed Mar 25 12:38:29 UTC 2020


commit bd228c774921e9e5112589bb0162cae23f8136cf
Author: Iain R. Learmonth <irl at fsfe.org>
Date:   Wed Mar 25 12:38:08 2020 +0000

    cloudformation: Allow SSH key to be overriden with env
---
 cloudformation/identify_user.sh | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/cloudformation/identify_user.sh b/cloudformation/identify_user.sh
index f01bbc5..470f28a 100755
--- a/cloudformation/identify_user.sh
+++ b/cloudformation/identify_user.sh
@@ -1,8 +1,20 @@
 #!/bin/zsh
-#aws ec2 describe-key-pairs | jq -r '.KeyPairs[].KeyName' | grep `aws iam get-user | jq -r .User.UserName`
+
+# If overridden with an environment variable, use that.
+if [[ -v $TOR_METRICS_SSH_KEY ]]; then
+	echo $TOR_METRICS_SSH_KEY
+	exit 0
+done
+
+# Otherwise, make a guess based on the username.
+#
+# The available key pairs can be found with:
+#
+#   aws ec2 describe-key-pairs | jq -r '.KeyPairs[].KeyName' | \
+#   grep `aws iam get-user | jq -r .User.UserName`
 declare -A keypairs
 keypairs[acute]="acute yubikey 4"
-keypairs[irl]="irl macbook 16"
+keypairs[irl]="irl yubikey 4"
 keypairs[karsten]="karsten's key"
 
 cur_user=$(aws iam get-user | jq -r .User.UserName)



More information about the tor-commits mailing list