【问题标题】:How to recreate ec2-user home directory如何重新创建 ec2-user 主目录
【发布时间】:2016-05-13 15:05:53
【问题描述】:

我在亚马逊 ec2 上的 rhel 实例上永久删除了我的 ec2-user 主目录

谢天谢地,我仍然登录到我的服务器

我没有目录或快照的任何备份副本

我知道我可以从我的私钥重新创建我的公钥,我还将我的公钥复制到 /home/ec2-user/.ssh/authorized_keys 这就是我重新创建公钥的方式

ssh-keygen -y -f test.pem > test.pub

由于某种原因,这些步骤还不够,我仍然无法 ssh 进入我的服务器

我是否缺少任何步骤?有人可以指导我吗?

这是我尝试登录时遇到的错误

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
xx.
Please contact your system administrator.
Add correct host key in /Users/xx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xx/.ssh/known_hosts:5
ECDSA host key for ec2-xx-xx-xx-xx.compute-1.amazonaws.com has changed and you have requested strict checking.
Host key verification failed.

【问题讨论】:

    标签: amazon-web-services ssh amazon-ec2 rhel


    【解决方案1】:

    将您的公钥复制到 /home/ec2-user/.ssh/authorized_keys 如果 .ssh 目录和 authorized_keys 文件不存在,则创建它们

    以 root 身份执行这些命令

    chown -R ec2-user /home/ec2-user 
    chmod 700 /home/ec2-user/.ssh
    chmod 600 /home/ec2-user/.ssh/authorized_keys
    

    然后尝试登录。认为这可能足以让它工作

    【讨论】:

      猜你喜欢
      • 2015-07-26
      • 1970-01-01
      • 1970-01-01
      • 2018-02-21
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 2010-11-26
      • 2010-10-09
      相关资源
      最近更新 更多