AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-06-28 · Documentation medium

File: code-library/latest/ug/ec2_example_ec2_ImportKeyPair_section.md

Summary

Added PowerShell V5 example for SSH key pair import

Security assessment

Documents secure key management practices but does not fix a vulnerability. Shows proper handling of cryptographic material which is security-adjacent.

Diff

diff --git a/code-library/latest/ug/ec2_example_ec2_ImportKeyPair_section.md b/code-library/latest/ug/ec2_example_ec2_ImportKeyPair_section.md
index a1b38e0f7..e9c342faa 100644
--- a//code-library/latest/ug/ec2_example_ec2_ImportKeyPair_section.md
+++ b//code-library/latest/ug/ec2_example_ec2_ImportKeyPair_section.md
@@ -82,0 +83,23 @@ PowerShell
+**Tools for PowerShell V5**
+    
+
+**Example 1: This example imports a public key to EC2. The first line stores the contents of the public key file (*.pub) in the variable`$publickey`. Next, the example converts the UTF8 format of the public key file to a Base64-encoded string, and stores the converted string in the variable `$pkbase64`. In the last line, the converted public key is imported to EC2. The cmdlet returns the key fingerprint and name as results.**
+    
+    
+    $publickey=[Io.File]::ReadAllText("C:\Users\TestUser\.ssh\id_rsa.pub")
+    $pkbase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($publickey))
+    Import-EC2KeyPair -KeyName Example-user-key -PublicKey $pkbase64
+    
+
+**Output:**
+    
+    
+    KeyFingerprint                                  KeyName
+    --------------                                  -------
+    do:d0:15:8f:79:97:12:be:00:fd:df:31:z3:b1:42:z1 Example-user-key
+
+  * For API details, see [ImportKeyPair](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. 
+
+
+
+