本文介绍了Amazon AWS EC2删除的密钥已锁定在根之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Amazon AWS EC2上运行Ubuntu实例。我有一个名为ubuntu的root用户。我还有一个名为ellis的用户。我的ubuntu用户是具有所有其他用户控制权并在根目录中创建文件和目录的管理用户。

I am running an Ubuntu instance on Amazon AWS EC2. I have a root user named ubuntu. I also have another user named ellis. My ubuntu user is the administrative user that has the control of all other users and creating files and directories in the root.

当我将.ssh / authorized_keys从/home/ubuntu/.ssh/authorized_keys复制到/home/ellis/.ssh时,我必须不小心删除了该目录。 ubuntu中的ssh。现在,我无法以ubuntu身份登录到我的实例,而只能以ellis身份登录。我尝试更改ellis中的权限以获得访问ubuntu的机会,但是没有运气。

When I was copying the .ssh/authorized_keys from /home/ubuntu/.ssh/authorized_keys to /home/ellis/.ssh I must have accidentally deleted the directory .ssh that was within ubuntu. Now, I am not able to login to my instance as ubuntu, only as ellis. I tried changing permissions within ellis to gain access to ubuntu with no luck.

我将FileZilla用作ellis并能够查看ubuntu中的目录和文件,这就是为什么我知道.ssh已从ubuntu中删除。

I used FileZilla as ellis and was able to see the directories and files within ubuntu, that is why I know that .ssh was removed from ubuntu.

我需要能够访问ubuntu。我尝试将ssh目录从ellis复制到ubuntu,但是使用已设置的权限,其他用户无法进行任何管理。有什么办法解决此问题?

I need to be able to access ubuntu. I have tried copying my ssh directory from ellis to ubuntu, but with the permissions that are set up, nothing administrative can be done from other users. Any way to fix this?

推荐答案

您仍然可以通过将磁盘附加到另一个实例来访问该磁盘。这样,您可以跨新的密钥文件进行复制。

You can still access the disk by attaching it to another instance. That way, you can copy across a new key file.

尝试以下操作:


  • 停止您的实例(我们将其称为实例A

  • 启动另一个Linux实例或使用您已有的实例(我们将其称为实例B

  • 从实例A分离您的根EBS卷(我们称为卷A )-记下挂载设备,例如 / dev / sda1

  • 通过控制台将卷A作为/ dev / sdf附加到实例B。
    尽管提供的设备名称为/ dev / sdf,但aws可能会将其附加为/ dev / xvdf或/ dev / xvdf1。
    如果您看不到/ dev / sdf或/ dev / xvdf或/ dev / xvdf1

  • Stop your instance (let's call it Instance A)
  • Start another Linux instance or use one you already have (let's call this Instance B)
  • Detach your root EBS Volume from Instance A (let's call this Volume A) -- make a note of the mount device, eg /dev/sda1
  • Attach Volume A to Instance B as some /dev/sdf via console.Though device name provided is /dev/sdf, aws might attach it as /dev/xvdf or /dev/xvdf1.You might have to reboot instance B, if you do not see either /dev/sdf or /dev/xvdf or /dev/xvdf1

尝试挂载卷/ dev / xvdf或/ dev / xvdf1,访问内容,导航到 ubuntu 用户的主目录,存储正确的ssh-key

Try to mount the volume /dev/xvdf or /dev/xvdf1, access the content, navigate to the ubuntu user's home directory, store a correct ssh-key

这篇关于Amazon AWS EC2删除的密钥已锁定在根之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 06:42