如何在不创建新ec2

编程入门 行业动态 更新时间:2024-10-10 10:25:00
本文介绍了如何在不创建新ec2-instance的情况下更改ec2-instance的pem文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经创建了一个实例及其名为demo.pem的pem文件,但是出于安全考虑,我不得不为同一实例将旧的demo.pem文件更改为demos.pem. 我不想创建用于更改pem文件的新实例 =>可以吗? |帮助?

I have created an instance and its pem file named as demo.pem, But due to some security i have to change my old demo.pem file with demos.pem for the same instance. I do not want to create new instance for changing pem file => Is it possible? | Help?

推荐答案

值得理解密钥对的工作原理...

It's worth understanding how keypairs work...

使用密钥对登录Linux时,您指定用户名和密钥对,例如:

When logging into Linux using keypairs, you specify a username and a keypair, eg:

ssh -i demo.pem ec2-user@54.11.22.33

然后,Linux查找属于该用户的.ssh/authorized_keys文件,例如:

Linux then looks in the .ssh/authorized_keys file belonging to that user, eg:

/home/users/ec2-user/.ssh/authorized_keys

如果在该文件中查找与用于登录的私钥匹配的公钥.然后,它会执行神奇的密钥对操作,并确定是否允许该人登录.

If looks for the public key in that file that matches the private key used for login. It then does keypair magical stuff and determines whether to allow the person to login.

因此,要使用新的密钥对在实例上启用登录:

  • 将密钥对的公共部分添加到相应用户主目录中的~/.ssh/authorized_keys文件中
  • 如果需要,请从该文件中删除旧密钥以删除访问权限
  • Add the public half of the keypair to the ~/.ssh/authorized_keys file in the appropriate user's home directory
  • If desired, remove an old key from that file to remove access permissions

该文件中可以有多个密钥,这些密钥允许通过任何授权的密钥对进行登录.

You can have multiple keys in that file, which permit login via any of the authorized keypairs.

更多推荐

如何在不创建新ec2

本文发布于:2023-11-24 12:09:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625146.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!