Score:0

Can I connect to that instance using aws cli commands instead of using ssh with private key pem file?

cn flag

I have an ec2 instance.

Can I connect to that instance using aws cli commands instead of using ssh with private key pem file?

My purpose is to connect to the ec2 instance if the user just provides ec2 instanceid or public ip.

If they provide instance id, I can fetch the public ip using below command.

aws ec2 describe-instances --instance-ids i-0d577af80725c9a91 --query 'Reservations[*].Instances[*].PublicIpAddress' --output text --profile testsubaccount --region us-east-1

I didn't find any steps so I thought creating a ssh key at runtime on the automation machine and use that, so I tried this link

aws ec2-instance-connect send-ssh-public-key     --instance-id i-0d577af80725c9a91     --instance-os-user ec2-user     --ssh-public-key file://.ssh/id_rsa.pub --profile testsubaccount --region us-east-1

got below output

{
    "RequestId": "2e261407-e8fe-46e6-b6b6-2f27c41a0f5c",
    "Success": true
}

But when I try to connect, I am getting access denied.

ssh -o "IdentitiesOnly=yes" -i .\.ssh\id_rsa [email protected]

[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.