send-ssh-public-key success but still can't connect with ssh
Describe the bug
I've use the command send-ssh-public-key which is described here: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2-instance-connect/send-ssh-public-key.html
Operation finishes with a success message:
aws ec2-instance-connect send-ssh-public-key --instance-id i-000000000000000 --ssh-public-key file://~/.ssh/id_rsa.pub --instance-os-user ubuntu --availability-zone us-east-1a
{
"RequestId": "10f---------------------------------------",
"Success": true
}
trying to connect to the instance using ssh:
ssh [email protected] -i ../.ssh/id_rsa
connection failed:
[email protected]: Permission denied (publickey).
Expected Behavior
SSH connection successful to the instance for 60 seconds using the sent key.
Current Behavior
Connection failed with message Permission denied (publickey).
Reproduction Steps
- Run the command described at: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2-instance-connect/send-ssh-public-key.html
(change i-000000000000000 with a correct instance id)
aws ec2-instance-connect send-ssh-public-key --instance-id i-000000000000000 --ssh-public-key file://~/.ssh/id_rsa.pub --instance-os-user ubuntu --availability-zone us-east-1a
- try to connect to the instance using ssh
Possible Solution
No response
Additional Information/Context
No response
CLI version used
aws-cli/2.2.21 Python/3.8.8 Darwin/21.2.0 exe/x86_64 prompt/off
Environment details (OS name and version, etc.)
aws cli ran on mac m1, instance os is ubuntu
Ok, I've found out that I need to Install EC2 Instance Connect on a ubuntu 18 (only included OOB on ubuntu 20 and above).
Is there a way to install it through the admin console?
because if I cant connect with ssh I cant run sudo apt-get install ec2-instance-connect ...
Hi @daviddayag, Thank you for submitting the issue. Depending on your operating system there are multiple ways you can connect to the Ubuntu instance to install EC2 Instance Connect. Here, are some pre requisites that would be essential in connecting to the instance along with the steps to successfully connect to the instance using SSH.
Hope this helps!
The problem is that I don’t have the original ssh keys. That’s why I want to use this to push new ones. And it’s imperative that the instance will stay up the whole time. I know I can use user-data to push new key but it requires taking the instance down, which is out of the question for us.
On Tue, 26 Apr 2022 at 1:06 Anish Oswal @.***> wrote:
Hi @daviddayag https://github.com/daviddayag, Thank you for submitting the issue. Depending on your operating system there are multiple ways you can connect to the Ubuntu instance https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html to install EC2 Instance Connect. Here https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html, are some pre requisites that would be essential in connecting to the instance along with the steps to successfully connect to the instance using SSH https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html .
Hope this helps!
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-cli/issues/6896#issuecomment-1109087471, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFTUTRSRZQYULUXZBS3LZDVG4JPRANCNFSM5UHWYUOQ . You are receiving this because you were mentioned.Message ID: @.***>
-- David Dayag
Hi @daviddayag, In case of lost key, the only other way would be to use user-data to push new key. As mentioned in the steps here, it would not be possible without stopping the instance.
Hope this helps!
Yes. I know this way it works :) thank you. As mentioned I am looking into a way of connecting with my instance staying up. Which I understand now that is impossible. Thanks anyway.
On Tue, 26 Apr 2022 at 2:05 Anish Oswal @.***> wrote:
Hi @daviddayag https://github.com/daviddayag, In case of lost key, the only other way would be to use user-data to push new key. As mentioned in the steps here https://aws.amazon.com/premiumsupport/knowledge-center/ec2-windows-replace-lost-key-pair/, it would not be possible without stopping the instance.
Hope this helps!
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-cli/issues/6896#issuecomment-1109122827, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFTUTS6R7RT4JWR72IQDKDVG4QL3ANCNFSM5UHWYUOQ . You are receiving this because you were mentioned.Message ID: @.***>
-- David Dayag
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.