Is it possible to log into a new EC2 instance for the first time using a non-default user?



    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.



  • 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).




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2