Add user to LINUX Virtual Machine

Contents
    1. Log into the machine as root or someone that can use the SUDO command.
    2. Create the user:
      • sudo useradd -d /home/NEWUSERNAME -s /bin/bash -m -G sudo NEWUSERNAME
    3. Change to a super user:
      • sudo su
    4. Change to new user’s home directory
      • cd /home/NEWUSERNAME
    5. Create .ssh folder and set permissions:
      • mkdir .ssh
      • chmod 700 ./.ssh
    6. Create authorized_keys file
      • nano authorized_keys
      • (paste public key)
      • Ctrl-O (write the file) then RETURN
      • Ctrl-X (exit)
    7. Edit sudoer file
      • nano /etc/sudoers.d/waagent
        • (create file if does not exist)
      • Add new line:
        • NEWUSERNAME ALL = (ALL) NOPASSWD: ALL
      • Ctrl-O (write the file) then RETURN
      • Ctrl-X (exit)

    Updated on July 11, 2025

    Leave a Reply

    Your email address will not be published. Required fields are marked *