繁体   English   中英

无法通过 SSH 连接到 EC2 实例 pem '.ssh/intuit-tke-qe.pem' 的权限 0777 太开放了'

[英]Unable to SSH into EC2 Instance pem 'Permissions 0777 for '.ssh/intuit-tke-qe.pem' are too open'

我无法通过 ssh 进入我的 EC2 实例,这似乎是我传递给 ssh 的 ssh .pem 文件的权限级别的问题,谷歌搜索这似乎是许多其他人面临的问题,但他们的解决方案没有不适合我。

这是我尝试过的,请有人帮忙...

尝试 1:

asemani$ ssh -i ~/.ssh/secure.pem root@54.210.0.1

********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system.  Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.

All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '.ssh/secure.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key ".ssh/secure.pem": bad permissions
Permission denied (publickey).

尝试 2:

asemani$ chmod 600 ~/.ssh/secure.pem 
asemani$ ls -l ~/.ssh/
total 56
-rw-r--r--  1 asemani  CORP\Domain Users    782 Apr 29 11:14 config
-rw-------@ 1 asemani  CORP\Domain Users   1696 Apr 29 21:32 secure.pem
asemani$ 
asemani$ ssh -i .ssh/secure.pem root@54.210.0.1
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system.  Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.

All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
Permission denied (publickey).

我不再收到警告,但权限仍然被拒绝。 然后我还尝试在 .pem 文件上执行chmod 400但这也不起作用。 我不会在这里粘贴,因为这可能有点矫枉过正。

这里发生了什么? 我怎样才能通过 ssh 进入我的 ec2? 这应该是一件很简单的事情吧??

将权限更改为chmod 400 ~/.ssh/secure.pem

您需要通过 AWS EC2 管理控制台启动实例。 启动后,复制公共 DNS IPv4 并将其粘贴到正在使用的 linux 发行版名称之后(例如 ubuntu@IPv4)。 此外,请确保您在存放您的私有访问密钥的目录中工作。

为澄清起见,一旦您的 EC2 实例启动并且您位于包含您的私有访问密钥的目录中,请在命令行中输入以下内容:

ssh -i private_access_key.pem linux@IPv4

您可以使用pem密钥以默认用户身份登录吗? 对于 Ubuntu 实例,默认用户应该是ubuntu 对于大多数其他情况,它应该是ec2-user 如果您能够以默认用户身份登录,则很可能不允许root进行ssh登录。 要更改它,请以默认用户身份登录并执行以下操作:

# Edit sshd_config and modify 'PermitRootLogin XX' to 'PermitRootLogin yes'
sudo vi /etc/ssh/sshd_config

# Reload sshd configuration
sudo service sshd reload

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM