简体   繁体   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'

I'm unable to ssh into my EC2 instance, seems to be an issue with the permission level of the ssh .pem file I'm passing to ssh, googling around this seems to be a problem many others have faced but their solutions didn't work for me.我无法通过 ssh 进入我的 EC2 实例,这似乎是我传递给 ssh 的 ssh .pem 文件的权限级别的问题,谷歌搜索这似乎是许多其他人面临的问题,但他们的解决方案没有不适合我。

Here is what I tried, someone please help...这是我尝试过的,请有人帮忙...

Atempt 1:尝试 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).

Attempt 2:尝试 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).

I don't get the warning anymore but Permission is still denied.我不再收到警告,但权限仍然被拒绝。 I then also tried doing a chmod 400 on the .pem file but that also didn't work.然后我还尝试在 .pem 文件上执行chmod 400但这也不起作用。 I won't paste that here since that may be overkill.我不会在这里粘贴,因为这可能有点矫枉过正。

What is happening here?这里发生了什么? How can I ssh into my ec2?我怎样才能通过 ssh 进入我的 ec2? This should be a simple thing??这应该是一件很简单的事情吧??

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

You need to launch the instance through your AWS EC2 management console.您需要通过 AWS EC2 管理控制台启动实例。 Once it is launched, copy the public DNS IPv4 and paste it after the linux distribution name being used (eg ubuntu@IPv4).启动后,复制公共 DNS IPv4 并将其粘贴到正在使用的 linux 发行版名称之后(例如 ubuntu@IPv4)。 Also, make sure you are working in the directory that houses your private access key.此外,请确保您在存放您的私有访问密钥的目录中工作。

For clarification, once your EC2 instance is launched and you're in the directory that holds your private access key, type in the following in the command-line:为澄清起见,一旦您的 EC2 实例启动并且您位于包含您的私有访问密钥的目录中,请在命令行中输入以下内容:

ssh -i private_access_key.pem linux@IPv4

Are you able to login as the default user using your pem key?您可以使用pem密钥以默认用户身份登录吗? For Ubuntu instances, default user should be ubuntu ;对于 Ubuntu 实例,默认用户应该是ubuntu for most other instances it should be ec2-user .对于大多数其他情况,它应该是ec2-user If you're able to login as the default user, chances are that root isn't allowed for ssh login.如果您能够以默认用户身份登录,则很可能不允许root进行ssh登录。 To change that, login as the default user and do the following:要更改它,请以默认用户身份登录并执行以下操作:

# 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