File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ if ($splitted_instance.Length -gt 1) {
2020 $env: AWS_DEFAULT_REGION = $splitted_instance [1 ]
2121}
2222
23- Write-Output " Add public key $ssh_public_key_path for $ssh_user at instance $instance_id for 60 seconds"
23+ Write-Output " Add public key $ssh_public_key_path for $ssh_user at instance $instance_id for 10 seconds"
2424$ssh_public_key = (Get-Content $ssh_public_key_path | Select-Object - first 1 )
2525aws ssm send-command `
2626 -- instance- ids " $instance_id " `
2727 -- document- name ' AWS-RunShellScript' `
28- -- comment " Add an SSH public key to authorized_keys for 60 seconds" `
28+ -- comment " Add an SSH public key to authorized_keys for 10 seconds" `
2929 -- parameters commands= @"
3030 \"
3131 set -eu
@@ -36,10 +36,10 @@ aws ssm send-command `
3636
3737 echo \\\"`$ authorized_key\\\" >> authorized_keys
3838
39- sleep 60
39+ sleep 10
4040
41- grep -v -F \\\"`$ authorized_key\\\" authorized_keys > ~ authorized_keys
42- mv ~ authorized_keys authorized_keys
41+ ( grep -v -F \\\"\ ${ authorized_key} \\\" authorized_keys || true) > authorized_keys~
42+ mv authorized_keys~ authorized_keys
4343 \"
4444 "@
4545
Original file line number Diff line number Diff line change 1919 instance_id=" ${instance_id%% ${REGION_SEPARATOR} * } "
2020fi
2121
22- > /dev/stderr echo " Add public key ${ssh_public_key_path} for ${ssh_user} at instance ${instance_id} for 60 seconds"
22+ > /dev/stderr echo " Add public key ${ssh_public_key_path} for ${ssh_user} at instance ${instance_id} for 10 seconds"
2323ssh_public_key=" $( cat " ${ssh_public_key_path} " ) "
2424aws ssm send-command \
2525 --instance-ids " ${instance_id} " \
2626 --document-name ' AWS-RunShellScript' \
27- --comment " Add an SSH public key to authorized_keys for 60 seconds" \
27+ --comment " Add an SSH public key to authorized_keys for 10 seconds" \
2828 --parameters commands="
2929 \"
3030 set -eu
@@ -35,10 +35,10 @@ aws ssm send-command \
3535
3636 echo \\\"\$ {authorized_key}\\\" >> authorized_keys
3737
38- sleep 60
38+ sleep 10
3939
40- grep -v -F \\\"\$ {authorized_key}\\\" authorized_keys > ~ authorized_keys
41- mv ~ authorized_keys authorized_keys
40+ ( grep -v -F \\\"\$ {authorized_key}\\\" authorized_keys || true) > authorized_keys~
41+ mv authorized_keys~ authorized_keys
4242 \"
4343 "
4444
You can’t perform that action at this time.
0 commit comments