Amazon EC2 密钥对

启动实例时,您指定密钥对。您可以指定现有的密钥对,也可以指定在启动时创建的新密钥对。在启动时,公有密钥内容放在实例上 ~/.ssh/authorized_keys 中的条目内。要登录实例,您必须在连接到实例时指定私有密钥。

丢失私有密钥时连接到 Linux 实例

如果丢失由 EBS 支持的实例的私有密钥,您可以重新获取对您的实例的访问权限。您必须停止实例,分离卷并将其作为数据卷附加到另一个实例,然后修改 authorized_keys 文件,将卷移回原始实例,并重启实例。

cp .ssh/authorized_keys /mnt/tempvol/home/ec2-user/.ssh/authorized_keys

sudo chown 222:500 /mnt/tempvol/home/ec2-user/.ssh/authorized_keys

[ec2-user ~]$ sudo ls -l /mnt/tempvol/home/ec2-user/.ssh

total 4

-rw------- 1 222 500 398 Sep 13 22:54 authorized_keys

https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/ec2-key-pairs.html?shortFooter=true#replacing-lost-key-pair

原文地址:https://www.cnblogs.com/cloudrivers/p/11331233.html