From 1375750fec0e00ae63a7bf23819b7cf6c476d20e Mon Sep 17 00:00:00 2001 From: Charles Gardner Date: Thu, 23 Jul 2020 10:41:36 -0700 Subject: [PATCH 1/2] Added a check for ensuring the .ssh directory exists. --- aws-ssm-ec2-proxy-command.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws-ssm-ec2-proxy-command.sh b/aws-ssm-ec2-proxy-command.sh index bd36086..cb445e1 100644 --- a/aws-ssm-ec2-proxy-command.sh +++ b/aws-ssm-ec2-proxy-command.sh @@ -51,7 +51,8 @@ aws ssm send-command \ --document-name 'AWS-RunShellScript' \ --comment "Add an SSH public key to authorized_keys for 60 seconds" \ --parameters commands="\" - cd ~${ssh_user}/.ssh || exit 1 + [ -f ~/${ssh_user}/.ssh ] || mkdir -p ~/${ssh_user}/.ssh + cd ~/${ssh_user}/.ssh || exit 1 authorized_key='${ssh_public_key} ssm-session' echo \\\"\${authorized_key}\\\" >> authorized_keys sleep 60 From 0aedcc014a59283fcfddfdef2edb6e703fa36b62 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Fri, 24 Jul 2020 11:50:38 +0200 Subject: [PATCH 2/2] Update aws-ssm-ec2-proxy-command.sh --- aws-ssm-ec2-proxy-command.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-ssm-ec2-proxy-command.sh b/aws-ssm-ec2-proxy-command.sh index cb445e1..d6f2fa0 100644 --- a/aws-ssm-ec2-proxy-command.sh +++ b/aws-ssm-ec2-proxy-command.sh @@ -51,7 +51,7 @@ aws ssm send-command \ --document-name 'AWS-RunShellScript' \ --comment "Add an SSH public key to authorized_keys for 60 seconds" \ --parameters commands="\" - [ -f ~/${ssh_user}/.ssh ] || mkdir -p ~/${ssh_user}/.ssh + mkdir -p ~/${ssh_user}/.ssh cd ~/${ssh_user}/.ssh || exit 1 authorized_key='${ssh_public_key} ssm-session' echo \\\"\${authorized_key}\\\" >> authorized_keys