服务器拒绝了我们的密钥,将authorized_keys权限设置为777 [英] Server refused our key, set authorized_keys perrmissions to 777

查看:63
本文介绍了服务器拒绝了我们的密钥,将authorized_keys权限设置为777的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从ec2实例上的主目录中复制了一些文件,出于懒惰,我运行了命令sudo chmod 777/home/ec2-user/*.我猜这使我的.ssh文件夹成为可能,而且authorized_keys也具有777特权.事实证明,如果将authorized_keys设置为777,则无法使用这些密钥将SSH SSH到该框中(因为其他用户可能已经对其进行了更新).

I was copying some files from my home directory on my ec2 instance, and in a fit of laziness, I ran the command sudo chmod 777 /home/ec2-user/*. I guess this made my .ssh folder and possibly the authorized_keys have 777 privileges as well. Well it turns out that if authorized_keys is set to 777, you cannot SSH into the box with those keys (since another user could have updated it).

我的问题是,如何解决此问题并再次登录我的盒子?这是一个ec2实例,所以我必须ssh入.

My question is, how can I fix this and log into my box again? This is an ec2 instance, so I have to ssh in.

推荐答案

要更改权限,您需要访问实例内部的文件.

To Change permissions you'll need to access the files that are inside the Instance.

由于您无法在Instance中使用ssh,因此需要执行以下操作:

Since you can't ssh in the Instance you'll need to do the following things:

  1. 安排应用程序的停机时间,因为您需要停止实例.
  2. 备份实例存储(临时卷)中的所有内容.
  3. 停止实例.
  4. 从有问题的EC2实例中分离卷.
  5. 将卷附加到另一个正常工作的EC2实例.
  6. chmod 更改为您的.ssh目录及其文件.
  7. 分离音量.
  8. 附加到有问题的EC2实例.
  9. 启动EC2实例.
  10. 尝试连接到EC2实例.
  1. Schedule a downtime for your application, because you'll need to stop the instance.
  2. Back-up everything inside the Instance Store(ephemeral volumes).
  3. Stop the instance.
  4. Detach the Volume from the EC2 instance in question.
  5. Attach the Volume to another working EC2 instance.
  6. Make the chmod changes to your .ssh directory and it's files.
  7. Detach the volume.
  8. Attach to the EC2 instance in question.
  9. Start the EC2 Instance.
  10. Try Connecting to the EC2 instance.

请注意,如果您没有为实例配置弹性IP,则IP地址将更改.

Please note that if you don't have Elastic IP configured for the Instance, the IP address will change.

有关将卷附加到EC2实例的更多信息,请参考此

For more information about attaching volume to EC2 instance refer to this AWS Documentation.

这篇关于服务器拒绝了我们的密钥,将authorized_keys权限设置为777的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆