- 最新
- 最多得票
- 最多評論
Hi,
The private ipv4 address is limited to be used with the AWS VPC where your instance resides, we cannot connect to that IP directly from outside the AWS network hence the timeout error. To connect to an instance we need to use the public IP address.
Assuming that you have created a key pair during the EC2 instance creation. The error "Permission denied (publickey)" indicates that the connection was denied due to the authentication failure with the private key file provided while trying to connect to the instance.
First, check if you are using the correct key file to authenticate the SSH connection and try connecting to the network -> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
Additionally, for EC2-Connect to work properly you need to allow inbound SSH traffic from the EC2 Instance Connect IP range in addition to your IP address. Please refer to the Configure network access to an instance section -> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html
In addition to the two docs that you have linnked to, and the docs linked in other answers, there is this one that deals exactly with the error message that you are getting - Permission denied (publickey) https://repost.aws/knowledge-center/ec2-linux-fix-permission-denied-errors
Is any of the advice in this document of any assistance?
Hi RWC, I checked the methods proposed in the issue you referred me to and tried method 4 which is more readily accessible than the others. I was able to repair SSH permissions with a user data script but when I deleted it (to prevent data deletion in the next reboot), the issue resumed. The other methods are more complex than trying a different a different cloud provider.
Can you try connecting with CloudShell? It's the little prompt icon in the top right: https://aws.amazon.com/cloudshell/
I'm experiencing the same issue, with my macbook pro m1 terminal, as well as aws cloudshell
相關內容
- 已提問 7 個月前
- AWS 官方已更新 2 年前
- AWS 官方已更新 1 年前
Many thanks Bisina, I've set up a new instance and key pair to test your suggestion and can now SSH to my instance
Unfortunately, I'm still getting permission issues. I was able connect to a new instances with a new set of key pairs, install software, but when trying to connect later, via my laptop or CloudShell I got:
ssh -i ~/.aws/kp.pem ubuntu@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com ubuntu@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com: Permission denied (publickey). [cloudshell-user@ip-10-6-111-134 ~]$ ssh -i kp.pem ubuntu@ec2-54-146-178-153.compute-1.amazonaws.com ssh: connect to host ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com port 22: Connection timed out
The Inbound rules allow for access from anywhere for testing purposes. When launching yet another machine with another key pair, I am able to connect. Incidentally, even when I was able to access the machine, I was frequently disconnected with a "broken pipe" message.