File tree 2 files changed +10
-10
lines changed
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) {
20
20
$env: AWS_DEFAULT_REGION = $splitted_instance [1 ]
21
21
}
22
22
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"
24
24
$ssh_public_key = (Get-Content $ssh_public_key_path | Select-Object - first 1 )
25
25
aws ssm send-command `
26
26
-- instance- ids " $instance_id " `
27
27
-- 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" `
29
29
-- parameters commands= @"
30
30
\"
31
31
set -eu
@@ -36,10 +36,10 @@ aws ssm send-command `
36
36
37
37
echo \\\"`$ authorized_key\\\" >> authorized_keys
38
38
39
- sleep 60
39
+ sleep 10
40
40
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
43
43
\"
44
44
"@
45
45
Original file line number Diff line number Diff line change 19
19
instance_id=" ${instance_id%% ${REGION_SEPARATOR} * } "
20
20
fi
21
21
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"
23
23
ssh_public_key=" $( cat " ${ssh_public_key_path} " ) "
24
24
aws ssm send-command \
25
25
--instance-ids " ${instance_id} " \
26
26
--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" \
28
28
--parameters commands="
29
29
\"
30
30
set -eu
@@ -35,10 +35,10 @@ aws ssm send-command \
35
35
36
36
echo \\\"\$ {authorized_key}\\\" >> authorized_keys
37
37
38
- sleep 60
38
+ sleep 10
39
39
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
42
42
\"
43
43
"
44
44
You can’t perform that action at this time.
0 commit comments