You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by je...@apache.org on 2023/01/18 02:42:36 UTC

[mxnet-ci] branch master updated: Use IMDSv2 for getting ssh key. (#61)

This is an automated email from the ASF dual-hosted git repository.

jevans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mxnet-ci.git


The following commit(s) were added to refs/heads/master by this push:
     new 2644873  Use IMDSv2 for getting ssh key. (#61)
2644873 is described below

commit 2644873e9b0b809bb16ab6dc3e215906c62e0f49
Author: Joe Evans <jo...@gmail.com>
AuthorDate: Tue Jan 17 18:42:31 2023 -0800

    Use IMDSv2 for getting ssh key. (#61)
---
 tools/ami-creator/userdata/mxnetwindows_gpu_win2019_cuda114_g3.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/ami-creator/userdata/mxnetwindows_gpu_win2019_cuda114_g3.txt b/tools/ami-creator/userdata/mxnetwindows_gpu_win2019_cuda114_g3.txt
index e61c254..47b1dd5 100644
--- a/tools/ami-creator/userdata/mxnetwindows_gpu_win2019_cuda114_g3.txt
+++ b/tools/ami-creator/userdata/mxnetwindows_gpu_win2019_cuda114_g3.txt
@@ -23,7 +23,8 @@ Start-Service ssh-agent
 Start-Service sshd
 
 # setup administrator ssh key
-Invoke-WebRequest -Uri http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key -OutFile C:\ProgramData\ssh\administrators_authorized_keys
+[string]$token = Invoke-RestMethod -Headers @{"X-aws-ec2-metadata-token-ttl-seconds" = "300"} -Method PUT -Uri http://169.254.169.254/latest/api/token
+Invoke-RestMethod -Headers @{"X-aws-ec2-metadata-token" = $token} -Method GET -Uri http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key -OutFile C:\ProgramData\ssh\administrators_authorized_keys
 icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r
 icacls C:\ProgramData\ssh\administrators_authorized_keys /grant "Administrators:(F)"
 Restart-Service -Name sshd, ssh-agent -Force