How to change the default aws instance user?



  • Depending on which OS AMI you used you create a new instance, it assigns it a default user. To change this user account follow this link along side this article.

    Note: Ideally you will want some like of federated login method.

    http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html

    Login as the ec2-user.

    $ sudo adduser  <name of user>
    $ sudo su - <username>
    $ mkdir .ssh
    $ chmod 700 .ssh
    $ touch .ssh/authorized_keys
    $ chmod 600 .ssh/authorized_keys
    $ vi .ssh/authorized_keys
    

    Paste in the ssh key same one as the ec2-user

    Add user to /etc/sudoers.d/90-cloud-init-users

    Test it out. If all good remove the ec2-user account

    Login as new user

    $ sudo userdel -r ec2-user
    

    Remove the ec2-user entry.

    $ sudo vi /etc/sudoers.d/90-cloud-init-users
    

Log in to reply
 

© Lightnetics 2024