此过程需要停止和启动您的 EC2 实例。请注意,实例存储卷中的数据将丢失。有关更多信息,请参阅确定实例的根设备类型。请务必备份您想保存在实例存储卷上的所有数据。
停止并重新启动实例会更改实例的公有 IP 地址。在将外部流量路由到您的实例时,最佳做法是使用弹性 IP 地址而不是公有 IP 地址。
方法 1:输入用户数据
Steps for connecting to an EBS-backed instance with a different key pair
Step 1: Create a new key pair
Step 2: Get information about the original instance and its root volume
Step 3: Stop the original instance
Step 4: Launch a temporary instance
Step 5: Detach the root volume from the original instance and attach it to the temporary instance
Step 6: Add the new public key to authorized_keys on the original volume mounted to the temporary instance
Step 7: Unmount and detach the original volume from the temporary instance, and reattach it to the original instance
Step 8: Connect to the original instance using the new key pair
Step 9: Clean up