diff --git a/aws-ssm-ec2-proxy-command.sh b/aws-ssm-ec2-proxy-command.sh index bd36086..d6f2fa0 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 + 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