Add user to LINUX Virtual Machine
- Log into the machine as root or someone that can use the SUDO command.
- Create the user:
- sudo useradd -d /home/NEWUSERNAME -s /bin/bash -m -G sudo NEWUSERNAME
- Change to a super user:
- Change to new user’s home directory
- Create .ssh folder and set permissions:
- mkdir .ssh
- chmod 700 ./.ssh
- Create authorized_keys file
- nano authorized_keys
- (paste public key)
- Ctrl-O (write the file) then RETURN
- Ctrl-X (exit)
- 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