Home > Enterprise >  Is there a way of disable creating a .pem file when launching an instance in AWS?
Is there a way of disable creating a .pem file when launching an instance in AWS?

Time:04-30

My question is about this: Let´s say a user wants to launch an instance in AWS. Is there a way to tell AWS to not let them launch it with a .pem file? Any help would be appreciated!

CodePudding user response:

When using the AWS CLI, the --key-name parameter is optional. From this link

The following run-instances example launches a single instance of type t2.micro into the default subnet for the current Region and associates it with the default subnet for the default VPC for the Region. The key pair is optional if you do not plan to connect to your instance using SSH (Linux) or RDP (Windows).

aws ec2 run-instances \
    --image-id ami-0abcdef1234567890 \
    --instance-type t2.micro \
    --key-name MyKeyPair

(Bold text mine) So you do not need to supply a key pair when creating from the CLI. However, it looks like the UI to spin up an EC2 requires the key pair though.

CodePudding user response:

While You Creating any AWS EC2 instance from the GUI console or AWS CLI, attaching KeyPair is always optional to it. an AWS EC2 instance can be created without using the .pem file and also if you configure the session manager, you can log in to it using AWS Console GUI.

aws ec2 run-instances
--image-id < ami-id>
--instance-type < instance-type>
--subnet-id < subnet-id>
--security-group-ids < security-group-id> < security-group-id>

you can remove this parameter in the CLI command and that will do the needful without.pem file.

--key-name < ec2-key-pair-name>

  • Related