1
  1. After launching a EC2 instance, do I have to always log into the instance for the first time, by SSH with the default user for the image of the instance? Or is it possible to first time log into a new instance, by a user not the default one?

  2. When launching a EC2 instance using either AWS CLI2 or Terraform, is it possible to specify a user to create and its authentication method (by specifying a EC2 private/public key pair created for AWS already), so that I will have a non-default user to log into the instance for the first time? Or creating a non-default user for a new instance can only be done under the default user's login session?

Thanks.

1

1 Answer 1

2

The users who are present in a newly launched EC2 instance are the ones that exist in the image you launch it from.

The images provided by the Linux distros tend to have only one default user, but you can build your own custom image with other users, and launch your EC2 servers from your image/images.

And there's cloud-init config that can create a user at launch time, too (as a comment pointed out already).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.